text:
# Automatically generated using Clang.jl wrap_c, version 0.0.0

using Compat

const unix = 1
const linux = 1
const CUDNN_MAJOR = 5
const CUDNN_MINOR = 1
const CUDNN_PATCHLEVEL = 10

# Skipping MacroDefinition: CUDNN_VERSION ( CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL ) #

const MB_LEN_MAX = 16

# Skipping MacroDefinition: LLONG_MIN ( - LLONG_MAX - 1 ) #

# const LLONG_MAX = __LONG_LONG_MAX__

# Skipping MacroDefinition: ULLONG_MAX ( LLONG_MAX * 2ULL + 1 ) #

const NR_OPEN = 1024
const NGROUPS_MAX = 65536
const ARG_MAX = 131072
const LINK_MAX = 127
const MAX_CANON = 255
const MAX_INPUT = 255
const NAME_MAX = 255
const PATH_MAX = 4096
const PIPE_BUF = 4096
const XATTR_NAME_MAX = 255
const XATTR_SIZE_MAX = 65536
const XATTR_LIST_MAX = 65536
const RTSIG_MAX = 32
const PTHREAD_KEYS_MAX = 1024
# const PTHREAD_DESTRUCTOR_ITERATIONS = _POSIX_THREAD_DESTRUCTOR_ITERATIONS
const AIO_PRIO_DELTA_MAX = 20
const PTHREAD_STACK_MIN = 16384
const DELAYTIMER_MAX = 2147483647
const TTY_NAME_MAX = 32
const LOGIN_NAME_MAX = 256
const HOST_NAME_MAX = 64
const MQ_PRIO_MAX = 32768
const SEM_VALUE_MAX = 2147483647
# const SSIZE_MAX = LONG_MAX
# const BC_BASE_MAX = _POSIX2_BC_BASE_MAX
# const BC_DIM_MAX = _POSIX2_BC_DIM_MAX
# const BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX
# const BC_STRING_MAX = _POSIX2_BC_STRING_MAX
const COLL_WEIGHTS_MAX = 255
# const EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX
#  const LINE_MAX = _POSIX2_LINE_MAX
const CHARCLASS_NAME_MAX = 2048

# Skipping MacroDefinition: RE_DUP_MAX ( 0x7fff ) #

const cudaHostAllocDefault = 0x00
const cudaHostAllocPortable = 0x01
const cudaHostAllocMapped = 0x02
const cudaHostAllocWriteCombined = 0x04
const cudaHostRegisterDefault = 0x00
const cudaHostRegisterPortable = 0x01
const cudaHostRegisterMapped = 0x02
const cudaHostRegisterIoMemory = 0x04
const cudaPeerAccessDefault = 0x00
const cudaStreamDefault = 0x00
const cudaStreamNonBlocking = 0x01

# Skipping MacroDefinition: cudaStreamLegacy ( ( cudaStream_t ) 0x1 ) /**
# * Per-thread stream handle
# *
# * Stream handle that can be passed as a cudaStream_t to use an implicit stream
# * with per-thread synchronization behavior.
# *
# * See details of the \link_sync_behavior
# */
# Skipping MacroDefinition: cudaStreamPerThread ( ( cudaStream_t ) 0x2 ) #

const cudaEventDefault = 0x00
const cudaEventBlockingSync = 0x01
const cudaEventDisableTiming = 0x02
const cudaEventInterprocess = 0x04
const cudaDeviceScheduleAuto = 0x00
const cudaDeviceScheduleSpin = 0x01
const cudaDeviceScheduleYield = 0x02
const cudaDeviceScheduleBlockingSync = 0x04
const cudaDeviceBlockingSync = 0x04
const cudaDeviceScheduleMask = 0x07
const cudaDeviceMapHost = 0x08
const cudaDeviceLmemResizeToMax = 0x10
const cudaDeviceMask = Float32(0x01)
const cudaArrayDefault = 0x00
const cudaArrayLayered = 0x01
const cudaArraySurfaceLoadStore = 0x02
const cudaArrayCubemap = 0x04
const cudaArrayTextureGather = 0x08
const cudaIpcMemLazyEnablePeerAccess = 0x01
const cudaMemAttachGlobal = 0x01
const cudaMemAttachHost = 0x02
const cudaMemAttachSingle = 0x04
const cudaOccupancyDefault = 0x00
const cudaOccupancyDisableCachingOverride = 0x01

# Skipping MacroDefinition: cudaCpuDeviceId ( ( int ) - 1 ) /**< Device id that represents the CPU */
# Skipping MacroDefinition: cudaInvalidDeviceId ( ( int ) - 2 ) /**< Device id that represents an invalid device */
# Skipping MacroDefinition: cudaDevicePropDontCare { { '\0' } , /* char   name[256];               */ 0 , /* size_t totalGlobalMem;          */ 0 , /* size_t sharedMemPerBlock;       */ 0 , /* int    regsPerBlock;            */ 0 , /* int    warpSize;                */ 0 , /* size_t memPitch;                */ 0 , /* int    maxThreadsPerBlock;      */ { 0 , 0 , 0 } , /* int    maxThreadsDim[3];        */ { 0 , 0 , 0 } , /* int    maxGridSize[3];          */ 0 , /* int    clockRate;               */ 0 , /* size_t totalConstMem;           */ - 1 , /* int    major;                   */ - 1 , /* int    minor;                   */ 0 , /* size_t textureAlignment;        */ 0 , /* size_t texturePitchAlignment    */ - 1 , /* int    deviceOverlap;           */ 0 , /* int    multiProcessorCount;     */ 0 , /* int    kernelExecTimeoutEnabled */ 0 , /* int    integrated               */ 0 , /* int    canMapHostMemory         */ 0 , /* int    computeMode              */ 0 , /* int    maxTexture1D             */ 0 , /* int    maxTexture1DMipmap       */ 0 , /* int    maxTexture1DLinear       */ { 0 , 0 } , /* int    maxTexture2D[2]          */ { 0 , 0 } , /* int    maxTexture2DMipmap[2]    */ { 0 , 0 , 0 } , /* int    maxTexture2DLinear[3]    */ { 0 , 0 } , /* int    maxTexture2DGather[2]    */ { 0 , 0 , 0 } , /* int    maxTexture3D[3]          */ { 0 , 0 , 0 } , /* int    maxTexture3DAlt[3]       */ 0 , /* int    maxTextureCubemap        */ { 0 , 0 } , /* int    maxTexture1DLayered[2]   */ { 0 , 0 , 0 } , /* int    maxTexture2DLayered[3]   */ { 0 , 0 } , /* int    maxTextureCubemapLayered[2] */ 0 , /* int    maxSurface1D             */ { 0 , 0 } , /* int    maxSurface2D[2]          */ { 0 , 0 , 0 } , /* int    maxSurface3D[3]          */ { 0 , 0 } , /* int    maxSurface1DLayered[2]   */ { 0 , 0 , 0 } , /* int    maxSurface2DLayered[3]   */ 0 , /* int    maxSurfaceCubemap        */ { 0 , 0 } , /* int    maxSurfaceCubemapLayered[2] */ 0 , /* size_t surfaceAlignment         */ 0 , /* int    concurrentKernels        */ 0 , /* int    ECCEnabled               */ 0 , /* int    pciBusID                 */ 0 , /* int    pciDeviceID              */ 0 , /* int    pciDomainID              */ 0 , /* int    tccDriver                */ 0 , /* int    asyncEngineCount         */ 0 , /* int    unifiedAddressing        */ 0 , /* int    memoryClockRate          */ 0 , /* int    memoryBusWidth           */ 0 , /* int    l2CacheSize              */ 0 , /* int    maxThreadsPerMultiProcessor */ 0 , /* int    streamPrioritiesSupported */ 0 , /* int    globalL1CacheSupported   */ 0 , /* int    localL1CacheSupported    */ 0 , /* size_t sharedMemPerMultiprocessor; */ 0 , /* int    regsPerMultiprocessor;   */ 0 , /* int    managedMemory            */ 0 , /* int    isMultiGpuBoard          */ 0 , /* int    multiGpuBoardGroupID     */ 0 , /* int    hostNativeAtomicSupported */ 0 , /* int    singleToDoublePrecisionPerfRatio */ 0 , /* int    pageableMemoryAccess     */ 0 , /* int    concurrentManagedAccess  */ } /**< Empty device properties */

const CUDA_IPC_HANDLE_SIZE = 64
const cudaSurfaceType1D = 0x01
const cudaSurfaceType2D = 0x02
const cudaSurfaceType3D = 0x03
const cudaSurfaceTypeCubemap = 0x0c
const cudaSurfaceType1DLayered = 0xf1
const cudaSurfaceType2DLayered = 0xf2
const cudaSurfaceTypeCubemapLayered = 0xfc
const cudaTextureType1D = 0x01
const cudaTextureType2D = 0x02
const cudaTextureType3D = 0x03
const cudaTextureTypeCubemap = 0x0c
const cudaTextureType1DLayered = 0xf1
const cudaTextureType2DLayered = 0xf2
const cudaTextureTypeCubemapLayered = 0xfc
const CUDART_VERSION = 8000
# const CUDART_DEVICE = __device__
const CUDNN_DIM_MAX = 8
const CUDNN_LRN_MIN_N = 1
const CUDNN_LRN_MAX_N = 16
const CUDNN_LRN_MIN_K = 1.0e-5
const CUDNN_LRN_MIN_BETA = 0.01
const CUDNN_BN_MIN_EPSILON = 1.0e-5

# begin enum cudaError
const cudaError = UInt32
const cudaSuccess = (UInt32)(0)
const cudaErrorMissingConfiguration = (UInt32)(1)
const cudaErrorMemoryAllocation = (UInt32)(2)
const cudaErrorInitializationError = (UInt32)(3)
const cudaErrorLaunchFailure = (UInt32)(4)
const cudaErrorPriorLaunchFailure = (UInt32)(5)
const cudaErrorLaunchTimeout = (UInt32)(6)
const cudaErrorLaunchOutOfResources = (UInt32)(7)
const cudaErrorInvalidDeviceFunction = (UInt32)(8)
const cudaErrorInvalidConfiguration = (UInt32)(9)
const cudaErrorInvalidDevice = (UInt32)(10)
const cudaErrorInvalidValue = (UInt32)(11)
const cudaErrorInvalidPitchValue = (UInt32)(12)
const cudaErrorInvalidSymbol = (UInt32)(13)
const cudaErrorMapBufferObjectFailed = (UInt32)(14)
const cudaErrorUnmapBufferObjectFailed = (UInt32)(15)
const cudaErrorInvalidHostPointer = (UInt32)(16)
const cudaErrorInvalidDevicePointer = (UInt32)(17)
const cudaErrorInvalidTexture = (UInt32)(18)
const cudaErrorInvalidTextureBinding = (UInt32)(19)
const cudaErrorInvalidChannelDescriptor = (UInt32)(20)
const cudaErrorInvalidMemcpyDirection = (UInt32)(21)
const cudaErrorAddressOfConstant = (UInt32)(22)
const cudaErrorTextureFetchFailed = (UInt32)(23)
const cudaErrorTextureNotBound = (UInt32)(24)
const cudaErrorSynchronizationError = (UInt32)(25)
const cudaErrorInvalidFilterSetting = (UInt32)(26)
const cudaErrorInvalidNormSetting = (UInt32)(27)
const cudaErrorMixedDeviceExecution = (UInt32)(28)
const cudaErrorCudartUnloading = (UInt32)(29)
const cudaErrorUnknown = (UInt32)(30)
const cudaErrorNotYetImplemented = (UInt32)(31)
const cudaErrorMemoryValueTooLarge = (UInt32)(32)
const cudaErrorInvalidResourceHandle = (UInt32)(33)
const cudaErrorNotReady = (UInt32)(34)
const cudaErrorInsufficientDriver = (UInt32)(35)
const cudaErrorSetOnActiveProcess = (UInt32)(36)
const cudaErrorInvalidSurface = (UInt32)(37)
const cudaErrorNoDevice = (UInt32)(38)
const cudaErrorECCUncorrectable = (UInt32)(39)
const cudaErrorSharedObjectSymbolNotFound = (UInt32)(40)
const cudaErrorSharedObjectInitFailed = (UInt32)(41)
const cudaErrorUnsupportedLimit = (UInt32)(42)
const cudaErrorDuplicateVariableName = (UInt32)(43)
const cudaErrorDuplicateTextureName = (UInt32)(44)
const cudaErrorDuplicateSurfaceName = (UInt32)(45)
const cudaErrorDevicesUnavailable = (UInt32)(46)
const cudaErrorInvalidKernelImage = (UInt32)(47)
const cudaErrorNoKernelImageForDevice = (UInt32)(48)
const cudaErrorIncompatibleDriverContext = (UInt32)(49)
const cudaErrorPeerAccessAlreadyEnabled = (UInt32)(50)
const cudaErrorPeerAccessNotEnabled = (UInt32)(51)
const cudaErrorDeviceAlreadyInUse = (UInt32)(54)
const cudaErrorProfilerDisabled = (UInt32)(55)
const cudaErrorProfilerNotInitialized = (UInt32)(56)
const cudaErrorProfilerAlreadyStarted = (UInt32)(57)
const cudaErrorProfilerAlreadyStopped = (UInt32)(58)
const cudaErrorAssert = (UInt32)(59)
const cudaErrorTooManyPeers = (UInt32)(60)
const cudaErrorHostMemoryAlreadyRegistered = (UInt32)(61)
const cudaErrorHostMemoryNotRegistered = (UInt32)(62)
const cudaErrorOperatingSystem = (UInt32)(63)
const cudaErrorPeerAccessUnsupported = (UInt32)(64)
const cudaErrorLaunchMaxDepthExceeded = (UInt32)(65)
const cudaErrorLaunchFileScopedTex = (UInt32)(66)
const cudaErrorLaunchFileScopedSurf = (UInt32)(67)
const cudaErrorSyncDepthExceeded = (UInt32)(68)
const cudaErrorLaunchPendingCountExceeded = (UInt32)(69)
const cudaErrorNotPermitted = (UInt32)(70)
const cudaErrorNotSupported = (UInt32)(71)
const cudaErrorHardwareStackError = (UInt32)(72)
const cudaErrorIllegalInstruction = (UInt32)(73)
const cudaErrorMisalignedAddress = (UInt32)(74)
const cudaErrorInvalidAddressSpace = (UInt32)(75)
const cudaErrorInvalidPc = (UInt32)(76)
const cudaErrorIllegalAddress = (UInt32)(77)
const cudaErrorInvalidPtx = (UInt32)(78)
const cudaErrorInvalidGraphicsContext = (UInt32)(79)
const cudaErrorNvlinkUncorrectable = (UInt32)(80)
const cudaErrorStartupFailure = (UInt32)(127)
const cudaErrorApiFailureBase = (UInt32)(10000)
# end enum cudaError

# begin enum cudaChannelFormatKind
const cudaChannelFormatKind = UInt32
const cudaChannelFormatKindSigned = (UInt32)(0)
const cudaChannelFormatKindUnsigned = (UInt32)(1)
const cudaChannelFormatKindFloat = (UInt32)(2)
const cudaChannelFormatKindNone = (UInt32)(3)
# end enum cudaChannelFormatKind

mutable struct cudaChannelFormatDesc
    x::Cint
    y::Cint
    z::Cint
    w::Cint
    f::cudaChannelFormatKind
end

mutable struct cudaArray
end

const cudaArray_t = Ptr{cudaArray}
const cudaArray_const_t = Ptr{cudaArray}

mutable struct cudaMipmappedArray
end

const cudaMipmappedArray_t = Ptr{cudaMipmappedArray}
const cudaMipmappedArray_const_t = Ptr{cudaMipmappedArray}

# begin enum cudaMemoryType
const cudaMemoryType = UInt32
const cudaMemoryTypeHost = (UInt32)(1)
const cudaMemoryTypeDevice = (UInt32)(2)
# end enum cudaMemoryType

# begin enum cudaMemcpyKind
const cudaMemcpyKind = UInt32
const cudaMemcpyHostToHost = (UInt32)(0)
const cudaMemcpyHostToDevice = (UInt32)(1)
const cudaMemcpyDeviceToHost = (UInt32)(2)
const cudaMemcpyDeviceToDevice = (UInt32)(3)
const cudaMemcpyDefault = (UInt32)(4)
# end enum cudaMemcpyKind

mutable struct cudaPitchedPtr
    ptr::Ptr{Void}
    pitch::Cint
    xsize::Cint
    ysize::Cint
end

mutable struct cudaExtent
    width::Cint
    height::Cint
    depth::Cint
end

mutable struct cudaPos
    x::Cint
    y::Cint
    z::Cint
end

mutable struct cudaMemcpy3DParms
    srcArray::cudaArray_t
    srcPos::cudaPos
    srcPtr::cudaPitchedPtr
    dstArray::cudaArray_t
    dstPos::cudaPos
    dstPtr::cudaPitchedPtr
    extent::cudaExtent
    kind::cudaMemcpyKind
end

mutable struct cudaMemcpy3DPeerParms
    srcArray::cudaArray_t
    srcPos::cudaPos
    srcPtr::cudaPitchedPtr
    srcDevice::Cint
    dstArray::cudaArray_t
    dstPos::cudaPos
    dstPtr::cudaPitchedPtr
    dstDevice::Cint
    extent::cudaExtent
end

mutable struct cudaGraphicsResource
end

# begin enum cudaGraphicsRegisterFlags
const cudaGraphicsRegisterFlags = UInt32
const cudaGraphicsRegisterFlagsNone = (UInt32)(0)
const cudaGraphicsRegisterFlagsReadOnly = (UInt32)(1)
const cudaGraphicsRegisterFlagsWriteDiscard = (UInt32)(2)
const cudaGraphicsRegisterFlagsSurfaceLoadStore = (UInt32)(4)
const cudaGraphicsRegisterFlagsTextureGather = (UInt32)(8)
# end enum cudaGraphicsRegisterFlags

# begin enum cudaGraphicsMapFlags
const cudaGraphicsMapFlags = UInt32
const cudaGraphicsMapFlagsNone = (UInt32)(0)
const cudaGraphicsMapFlagsReadOnly = (UInt32)(1)
const cudaGraphicsMapFlagsWriteDiscard = (UInt32)(2)
# end enum cudaGraphicsMapFlags

# begin enum cudaGraphicsCubeFace
const cudaGraphicsCubeFace = UInt32
const cudaGraphicsCubeFacePositiveX = (UInt32)(0)
const cudaGraphicsCubeFaceNegativeX = (UInt32)(1)
const cudaGraphicsCubeFacePositiveY = (UInt32)(2)
const cudaGraphicsCubeFaceNegativeY = (UInt32)(3)
const cudaGraphicsCubeFacePositiveZ = (UInt32)(4)
const cudaGraphicsCubeFaceNegativeZ = (UInt32)(5)
# end enum cudaGraphicsCubeFace

# begin enum cudaResourceType
const cudaResourceType = UInt32
const cudaResourceTypeArray = (UInt32)(0)
const cudaResourceTypeMipmappedArray = (UInt32)(1)
const cudaResourceTypeLinear = (UInt32)(2)
const cudaResourceTypePitch2D = (UInt32)(3)
# end enum cudaResourceType

# begin enum cudaResourceViewFormat
const cudaResourceViewFormat = UInt32
const cudaResViewFormatNone = (UInt32)(0)
const cudaResViewFormatUnsignedChar1 = (UInt32)(1)
const cudaResViewFormatUnsignedChar2 = (UInt32)(2)
const cudaResViewFormatUnsignedChar4 = (UInt32)(3)
const cudaResViewFormatSignedChar1 = (UInt32)(4)
const cudaResViewFormatSignedChar2 = (UInt32)(5)
const cudaResViewFormatSignedChar4 = (UInt32)(6)
const cudaResViewFormatUnsignedShort1 = (UInt32)(7)
const cudaResViewFormatUnsignedShort2 = (UInt32)(8)
const cudaResViewFormatUnsignedShort4 = (UInt32)(9)
const cudaResViewFormatSignedShort1 = (UInt32)(10)
const cudaResViewFormatSignedShort2 = (UInt32)(11)
const cudaResViewFormatSignedShort4 = (UInt32)(12)
const cudaResViewFormatUnsignedInt1 = (UInt32)(13)
const cudaResViewFormatUnsignedInt2 = (UInt32)(14)
const cudaResViewFormatUnsignedInt4 = (UInt32)(15)
const cudaResViewFormatSignedInt1 = (UInt32)(16)
const cudaResViewFormatSignedInt2 = (UInt32)(17)
const cudaResViewFormatSignedInt4 = (UInt32)(18)
const cudaResViewFormatHalf1 = (UInt32)(19)
const cudaResViewFormatHalf2 = (UInt32)(20)
const cudaResViewFormatHalf4 = (UInt32)(21)
const cudaResViewFormatFloat1 = (UInt32)(22)
const cudaResViewFormatFloat2 = (UInt32)(23)
const cudaResViewFormatFloat4 = (UInt32)(24)
const cudaResViewFormatUnsignedBlockCompressed1 = (UInt32)(25)
const cudaResViewFormatUnsignedBlockCompressed2 = (UInt32)(26)
const cudaResViewFormatUnsignedBlockCompressed3 = (UInt32)(27)
const cudaResViewFormatUnsignedBlockCompressed4 = (UInt32)(28)
const cudaResViewFormatSignedBlockCompressed4 = (UInt32)(29)
const cudaResViewFormatUnsignedBlockCompressed5 = (UInt32)(30)
const cudaResViewFormatSignedBlockCompressed5 = (UInt32)(31)
const cudaResViewFormatUnsignedBlockCompressed6H = (UInt32)(32)
const cudaResViewFormatSignedBlockCompressed6H = (UInt32)(33)
const cudaResViewFormatUnsignedBlockCompressed7 = (UInt32)(34)
# end enum cudaResourceViewFormat

mutable struct cudaResourceDesc
    resType::cudaResourceType
    res::Void
end

mutable struct cudaResourceViewDesc
    format::cudaResourceViewFormat
    width::Cint
    height::Cint
    depth::Cint
    firstMipmapLevel::UInt32
    lastMipmapLevel::UInt32
    firstLayer::UInt32
    lastLayer::UInt32
end

mutable struct cudaPointerAttributes
    memoryType::cudaMemoryType
    device::Cint
    devicePointer::Ptr{Void}
    hostPointer::Ptr{Void}
    isManaged::Cint
end

mutable struct cudaFuncAttributes
    sharedSizeBytes::Cint
    constSizeBytes::Cint
    localSizeBytes::Cint
    maxThreadsPerBlock::Cint
    numRegs::Cint
    ptxVersion::Cint
    binaryVersion::Cint
    cacheModeCA::Cint
end

# begin enum cudaFuncCache
const cudaFuncCache = UInt32
const cudaFuncCachePreferNone = (UInt32)(0)
const cudaFuncCachePreferShared = (UInt32)(1)
const cudaFuncCachePreferL1 = (UInt32)(2)
const cudaFuncCachePreferEqual = (UInt32)(3)
# end enum cudaFuncCache

# begin enum cudaSharedMemConfig
const cudaSharedMemConfig = UInt32
const cudaSharedMemBankSizeDefault = (UInt32)(0)
const cudaSharedMemBankSizeFourByte = (UInt32)(1)
const cudaSharedMemBankSizeEightByte = (UInt32)(2)
# end enum cudaSharedMemConfig

# begin enum cudaComputeMode
const cudaComputeMode = UInt32
const cudaComputeModeDefault = (UInt32)(0)
const cudaComputeModeExclusive = (UInt32)(1)
const cudaComputeModeProhibited = (UInt32)(2)
const cudaComputeModeExclusiveProcess = (UInt32)(3)
# end enum cudaComputeMode

# begin enum cudaLimit
const cudaLimit = UInt32
const cudaLimitStackSize = (UInt32)(0)
const cudaLimitPrintfFifoSize = (UInt32)(1)
const cudaLimitMallocHeapSize = (UInt32)(2)
const cudaLimitDevRuntimeSyncDepth = (UInt32)(3)
const cudaLimitDevRuntimePendingLaunchCount = (UInt32)(4)
# end enum cudaLimit

# begin enum cudaMemoryAdvise
const cudaMemoryAdvise = UInt32
const cudaMemAdviseSetReadMostly = (UInt32)(1)
const cudaMemAdviseUnsetReadMostly = (UInt32)(2)
const cudaMemAdviseSetPreferredLocation = (UInt32)(3)
const cudaMemAdviseUnsetPreferredLocation = (UInt32)(4)
const cudaMemAdviseSetAccessedBy = (UInt32)(5)
const cudaMemAdviseUnsetAccessedBy = (UInt32)(6)
# end enum cudaMemoryAdvise

# begin enum cudaMemRangeAttribute
const cudaMemRangeAttribute = UInt32
const cudaMemRangeAttributeReadMostly = (UInt32)(1)
const cudaMemRangeAttributePreferredLocation = (UInt32)(2)
const cudaMemRangeAttributeAccessedBy = (UInt32)(3)
const cudaMemRangeAttributeLastPrefetchLocation = (UInt32)(4)
# end enum cudaMemRangeAttribute

# begin enum cudaOutputMode
const cudaOutputMode = UInt32
const cudaKeyValuePair = (UInt32)(0)
const cudaCSV = (UInt32)(1)
# end enum cudaOutputMode

# begin enum cudaDeviceAttr
const cudaDeviceAttr = UInt32
const cudaDevAttrMaxThreadsPerBlock = (UInt32)(1)
const cudaDevAttrMaxBlockDimX = (UInt32)(2)
const cudaDevAttrMaxBlockDimY = (UInt32)(3)
const cudaDevAttrMaxBlockDimZ = (UInt32)(4)
const cudaDevAttrMaxGridDimX = (UInt32)(5)
const cudaDevAttrMaxGridDimY = (UInt32)(6)
const cudaDevAttrMaxGridDimZ = (UInt32)(7)
const cudaDevAttrMaxSharedMemoryPerBlock = (UInt32)(8)
const cudaDevAttrTotalConstantMemory = (UInt32)(9)
const cudaDevAttrWarpSize = (UInt32)(10)
const cudaDevAttrMaxPitch = (UInt32)(11)
const cudaDevAttrMaxRegistersPerBlock = (UInt32)(12)
const cudaDevAttrClockRate = (UInt32)(13)
const cudaDevAttrTextureAlignment = (UInt32)(14)
const cudaDevAttrGpuOverlap = (UInt32)(15)
const cudaDevAttrMultiProcessorCount = (UInt32)(16)
const cudaDevAttrKernelExecTimeout = (UInt32)(17)
const cudaDevAttrIntegrated = (UInt32)(18)
const cudaDevAttrCanMapHostMemory = (UInt32)(19)
const cudaDevAttrComputeMode = (UInt32)(20)
const cudaDevAttrMaxTexture1DWidth = (UInt32)(21)
const cudaDevAttrMaxTexture2DWidth = (UInt32)(22)
const cudaDevAttrMaxTexture2DHeight = (UInt32)(23)
const cudaDevAttrMaxTexture3DWidth = (UInt32)(24)
const cudaDevAttrMaxTexture3DHeight = (UInt32)(25)
const cudaDevAttrMaxTexture3DDepth = (UInt32)(26)
const cudaDevAttrMaxTexture2DLayeredWidth = (UInt32)(27)
const cudaDevAttrMaxTexture2DLayeredHeight = (UInt32)(28)
const cudaDevAttrMaxTexture2DLayeredLayers = (UInt32)(29)
const cudaDevAttrSurfaceAlignment = (UInt32)(30)
const cudaDevAttrConcurrentKernels = (UInt32)(31)
const cudaDevAttrEccEnabled = (UInt32)(32)
const cudaDevAttrPciBusId = (UInt32)(33)
const cudaDevAttrPciDeviceId = (UInt32)(34)
const cudaDevAttrTccDriver = (UInt32)(35)
const cudaDevAttrMemoryClockRate = (UInt32)(36)
const cudaDevAttrGlobalMemoryBusWidth = (UInt32)(37)
const cudaDevAttrL2CacheSize = (UInt32)(38)
const cudaDevAttrMaxThreadsPerMultiProcessor = (UInt32)(39)
const cudaDevAttrAsyncEngineCount = (UInt32)(40)
const cudaDevAttrUnifiedAddressing = (UInt32)(41)
const cudaDevAttrMaxTexture1DLayeredWidth = (UInt32)(42)
const cudaDevAttrMaxTexture1DLayeredLayers = (UInt32)(43)
const cudaDevAttrMaxTexture2DGatherWidth = (UInt32)(45)
const cudaDevAttrMaxTexture2DGatherHeight = (UInt32)(46)
const cudaDevAttrMaxTexture3DWidthAlt = (UInt32)(47)
const cudaDevAttrMaxTexture3DHeightAlt = (UInt32)(48)
const cudaDevAttrMaxTexture3DDepthAlt = (UInt32)(49)
const cudaDevAttrPciDomainId = (UInt32)(50)
const cudaDevAttrTexturePitchAlignment = (UInt32)(51)
const cudaDevAttrMaxTextureCubemapWidth = (UInt32)(52)
const cudaDevAttrMaxTextureCubemapLayeredWidth = (UInt32)(53)
const cudaDevAttrMaxTextureCubemapLayeredLayers = (UInt32)(54)
const cudaDevAttrMaxSurface1DWidth = (UInt32)(55)
const cudaDevAttrMaxSurface2DWidth = (UInt32)(56)
const cudaDevAttrMaxSurface2DHeight = (UInt32)(57)
const cudaDevAttrMaxSurface3DWidth = (UInt32)(58)
const cudaDevAttrMaxSurface3DHeight = (UInt32)(59)
const cudaDevAttrMaxSurface3DDepth = (UInt32)(60)
const cudaDevAttrMaxSurface1DLayeredWidth = (UInt32)(61)
const cudaDevAttrMaxSurface1DLayeredLayers = (UInt32)(62)
const cudaDevAttrMaxSurface2DLayeredWidth = (UInt32)(63)
const cudaDevAttrMaxSurface2DLayeredHeight = (UInt32)(64)
const cudaDevAttrMaxSurface2DLayeredLayers = (UInt32)(65)
const cudaDevAttrMaxSurfaceCubemapWidth = (UInt32)(66)
const cudaDevAttrMaxSurfaceCubemapLayeredWidth = (UInt32)(67)
const cudaDevAttrMaxSurfaceCubemapLayeredLayers = (UInt32)(68)
const cudaDevAttrMaxTexture1DLinearWidth = (UInt32)(69)
const cudaDevAttrMaxTexture2DLinearWidth = (UInt32)(70)
const cudaDevAttrMaxTexture2DLinearHeight = (UInt32)(71)
const cudaDevAttrMaxTexture2DLinearPitch = (UInt32)(72)
const cudaDevAttrMaxTexture2DMipmappedWidth = (UInt32)(73)
const cudaDevAttrMaxTexture2DMipmappedHeight = (UInt32)(74)
const cudaDevAttrComputeCapabilityMajor = (UInt32)(75)
const cudaDevAttrComputeCapabilityMinor = (UInt32)(76)
const cudaDevAttrMaxTexture1DMipmappedWidth = (UInt32)(77)
const cudaDevAttrStreamPrioritiesSupported = (UInt32)(78)
const cudaDevAttrGlobalL1CacheSupported = (UInt32)(79)
const cudaDevAttrLocalL1CacheSupported = (UInt32)(80)
const cudaDevAttrMaxSharedMemoryPerMultiprocessor = (UInt32)(81)
const cudaDevAttrMaxRegistersPerMultiprocessor = (UInt32)(82)
const cudaDevAttrManagedMemory = (UInt32)(83)
const cudaDevAttrIsMultiGpuBoard = (UInt32)(84)
const cudaDevAttrMultiGpuBoardGroupID = (UInt32)(85)
const cudaDevAttrHostNativeAtomicSupported = (UInt32)(86)
const cudaDevAttrSingleToDoublePrecisionPerfRatio = (UInt32)(87)
const cudaDevAttrPageableMemoryAccess = (UInt32)(88)
const cudaDevAttrConcurrentManagedAccess = (UInt32)(89)
const cudaDevAttrComputePreemptionSupported = (UInt32)(90)
const cudaDevAttrCanUseHostPointerForRegisteredMem = (UInt32)(91)
# end enum cudaDeviceAttr

# begin enum cudaDeviceP2PAttr
const cudaDeviceP2PAttr = UInt32
const cudaDevP2PAttrPerformanceRank = (UInt32)(1)
const cudaDevP2PAttrAccessSupported = (UInt32)(2)
const cudaDevP2PAttrNativeAtomicSupported = (UInt32)(3)
# end enum cudaDeviceP2PAttr

mutable struct cudaDeviceProp
    name::NTuple{256, UInt8}
    totalGlobalMem::Cint
    sharedMemPerBlock::Cint
    regsPerBlock::Cint
    warpSize::Cint
    memPitch::Cint
    maxThreadsPerBlock::Cint
    maxThreadsDim::NTuple{3, Cint}
    maxGridSize::NTuple{3, Cint}
    clockRate::Cint
    totalConstMem::Cint
    major::Cint
    minor::Cint
    textureAlignment::Cint
    texturePitchAlignment::Cint
    deviceOverlap::Cint
    multiProcessorCount::Cint
    kernelExecTimeoutEnabled::Cint
    integrated::Cint
    canMapHostMemory::Cint
    computeMode::Cint
    maxTexture1D::Cint
    maxTexture1DMipmap::Cint
    maxTexture1DLinear::Cint
    maxTexture2D::NTuple{2, Cint}
    maxTexture2DMipmap::NTuple{2, Cint}
    maxTexture2DLinear::NTuple{3, Cint}
    maxTexture2DGather::NTuple{2, Cint}
    maxTexture3D::NTuple{3, Cint}
    maxTexture3DAlt::NTuple{3, Cint}
    maxTextureCubemap::Cint
    maxTexture1DLayered::NTuple{2, Cint}
    maxTexture2DLayered::NTuple{3, Cint}
    maxTextureCubemapLayered::NTuple{2, Cint}
    maxSurface1D::Cint
    maxSurface2D::NTuple{2, Cint}
    maxSurface3D::NTuple{3, Cint}
    maxSurface1DLayered::NTuple{2, Cint}
    maxSurface2DLayered::NTuple{3, Cint}
    maxSurfaceCubemap::Cint
    maxSurfaceCubemapLayered::NTuple{2, Cint}
    surfaceAlignment::Cint
    concurrentKernels::Cint
    ECCEnabled::Cint
    pciBusID::Cint
    pciDeviceID::Cint
    pciDomainID::Cint
    tccDriver::Cint
    asyncEngineCount::Cint
    unifiedAddressing::Cint
    memoryClockRate::Cint
    memoryBusWidth::Cint
    l2CacheSize::Cint
    maxThreadsPerMultiProcessor::Cint
    streamPrioritiesSupported::Cint
    globalL1CacheSupported::Cint
    localL1CacheSupported::Cint
    sharedMemPerMultiprocessor::Cint
    regsPerMultiprocessor::Cint
    managedMemory::Cint
    isMultiGpuBoard::Cint
    multiGpuBoardGroupID::Cint
    hostNativeAtomicSupported::Cint
    singleToDoublePrecisionPerfRatio::Cint
    pageableMemoryAccess::Cint
    concurrentManagedAccess::Cint
end

mutable struct cudaIpcEventHandle_st
    reserved::NTuple{64, UInt8}
end

mutable struct cudaIpcEventHandle_t
    reserved::NTuple{64, UInt8}
end

mutable struct cudaIpcMemHandle_st
    reserved::NTuple{64, UInt8}
end

mutable struct cudaIpcMemHandle_t
    reserved::NTuple{64, UInt8}
end

const cudaError_t = cudaError
# $(Expr(:typealias, :cudaError_t, :cudaError))

mutable struct CUstream_st
end

const cudaStream_t = Ptr{CUstream_st}
# $(Expr(:typealias, :cudaStream_t, :(Ptr{CUstream_st})))

mutable struct CUevent_st
end

const cudaEvent_t = Ptr{CUevent_st}
const cudaGraphicsResource_t = Ptr{cudaGraphicsResource}
# $(Expr(:typealias, :cudaEvent_t, :(Ptr{CUevent_st})))
# $(Expr(:typealias, :cudaGraphicsResource_t, :(Ptr{cudaGraphicsResource})))

mutable struct CUuuid_st
end

const cudaUUID_t = Void
const cudaOutputMode_t = cudaOutputMode
# $(Expr(:typealias, :cudaUUID_t, :Void))
# $(Expr(:typealias, :cudaOutputMode_t, :cudaOutputMode))

# begin enum cudaRoundMode
const cudaRoundMode = UInt32
const cudaRoundNearest = (UInt32)(0)
const cudaRoundZero = (UInt32)(1)
const cudaRoundPosInf = (UInt32)(2)
const cudaRoundMinInf = (UInt32)(3)
# end enum cudaRoundMode

# begin enum cudaSurfaceBoundaryMode
const cudaSurfaceBoundaryMode = UInt32
const cudaBoundaryModeZero = (UInt32)(0)
const cudaBoundaryModeClamp = (UInt32)(1)
const cudaBoundaryModeTrap = (UInt32)(2)
# end enum cudaSurfaceBoundaryMode

# begin enum cudaSurfaceFormatMode
const cudaSurfaceFormatMode = UInt32
const cudaFormatModeForced = (UInt32)(0)
const cudaFormatModeAuto = (UInt32)(1)
# end enum cudaSurfaceFormatMode

mutable struct surfaceReference
    channelDesc::cudaChannelFormatDesc
end

const cudaSurfaceObject_t = Culonglong
# $(Expr(:typealias, :cudaSurfaceObject_t, :Culonglong))

# begin enum cudaTextureAddressMode
const cudaTextureAddressMode = UInt32
const cudaAddressModeWrap = (UInt32)(0)
const cudaAddressModeClamp = (UInt32)(1)
const cudaAddressModeMirror = (UInt32)(2)
const cudaAddressModeBorder = (UInt32)(3)
# end enum cudaTextureAddressMode

# begin enum cudaTextureFilterMode
const cudaTextureFilterMode = UInt32
const cudaFilterModePoint = (UInt32)(0)
const cudaFilterModeLinear = (UInt32)(1)
# end enum cudaTextureFilterMode

# begin enum cudaTextureReadMode
const cudaTextureReadMode = UInt32
const cudaReadModeElementType = (UInt32)(0)
const cudaReadModeNormalizedFloat = (UInt32)(1)
# end enum cudaTextureReadMode

mutable struct textureReference
    normalized::Cint
    filterMode::cudaTextureFilterMode
    addressMode::NTuple{3, cudaTextureAddressMode}
    channelDesc::cudaChannelFormatDesc
    sRGB::Cint
    maxAnisotropy::UInt32
    mipmapFilterMode::cudaTextureFilterMode
    mipmapLevelBias::Cfloat
    minMipmapLevelClamp::Cfloat
    maxMipmapLevelClamp::Cfloat
    __cudaReserved::NTuple{15, Cint}
end

mutable struct cudaTextureDesc
    addressMode::NTuple{3, cudaTextureAddressMode}
    filterMode::cudaTextureFilterMode
    readMode::cudaTextureReadMode
    sRGB::Cint
    borderColor::NTuple{4, Cfloat}
    normalizedCoords::Cint
    maxAnisotropy::UInt32
    mipmapFilterMode::cudaTextureFilterMode
    mipmapLevelBias::Cfloat
    minMipmapLevelClamp::Cfloat
    maxMipmapLevelClamp::Cfloat
end

const cudaTextureObject_t = Culonglong
# $(Expr(:typealias, :cudaTextureObject_t, :Culonglong))

mutable struct char1
    x::UInt8
end

mutable struct uchar1
    x::Cuchar
end

mutable struct char3
    x::UInt8
    y::UInt8
    z::UInt8
end

mutable struct uchar3
    x::Cuchar
    y::Cuchar
    z::Cuchar
end

mutable struct short1
    x::Int16
end

mutable struct ushort1
    x::UInt16
end

mutable struct short3
    x::Int16
    y::Int16
    z::Int16
end

mutable struct ushort3
    x::UInt16
    y::UInt16
    z::UInt16
end

mutable struct int1
    x::Cint
end

mutable struct uint1
    x::UInt32
end

mutable struct int3
    x::Cint
    y::Cint
    z::Cint
end

mutable struct uint3
    x::UInt32
    y::UInt32
    z::UInt32
end

mutable struct long1
    x::Clong
end

mutable struct ulong1
    x::Culong
end

mutable struct long3
    x::Clong
    y::Clong
    z::Clong
end

mutable struct ulong3
    x::Culong
    y::Culong
    z::Culong
end

mutable struct float1
    x::Cfloat
end

mutable struct float3
    x::Cfloat
    y::Cfloat
    z::Cfloat
end

mutable struct longlong1
    x::Clonglong
end

mutable struct ulonglong1
    x::Culonglong
end

mutable struct longlong3
    x::Clonglong
    y::Clonglong
    z::Clonglong
end

mutable struct ulonglong3
    x::Culonglong
    y::Culonglong
    z::Culonglong
end

mutable struct double1
    x::Cdouble
end

mutable struct double3
    x::Cdouble
    y::Cdouble
    z::Cdouble
end

mutable struct dim3
    x::UInt32
    y::UInt32
    z::UInt32
end

# begin enum cudaDataType_t
const cudaDataType_t = UInt32
const CUDA_R_16F = (UInt32)(2)
const CUDA_C_16F = (UInt32)(6)
const CUDA_R_32F = (UInt32)(0)
const CUDA_C_32F = (UInt32)(4)
const CUDA_R_64F = (UInt32)(1)
const CUDA_C_64F = (UInt32)(5)
const CUDA_R_8I = (UInt32)(3)
const CUDA_C_8I = (UInt32)(7)
const CUDA_R_8U = (UInt32)(8)
const CUDA_C_8U = (UInt32)(9)
const CUDA_R_32I = (UInt32)(10)
const CUDA_C_32I = (UInt32)(11)
const CUDA_R_32U = (UInt32)(12)
const CUDA_C_32U = (UInt32)(13)
# end enum cudaDataType_t

# begin enum cudaDataType
const cudaDataType = UInt32
const CUDA_R_16F = (UInt32)(2)
const CUDA_C_16F = (UInt32)(6)
const CUDA_R_32F = (UInt32)(0)
const CUDA_C_32F = (UInt32)(4)
const CUDA_R_64F = (UInt32)(1)
const CUDA_C_64F = (UInt32)(5)
const CUDA_R_8I = (UInt32)(3)
const CUDA_C_8I = (UInt32)(7)
const CUDA_R_8U = (UInt32)(8)
const CUDA_C_8U = (UInt32)(9)
const CUDA_R_32I = (UInt32)(10)
const CUDA_C_32I = (UInt32)(11)
const CUDA_R_32U = (UInt32)(12)
const CUDA_C_32U = (UInt32)(13)
# end enum cudaDataType

# begin enum libraryPropertyType_t
const libraryPropertyType_t = UInt32
const MAJOR_VERSION = (UInt32)(0)
const MINOR_VERSION = (UInt32)(1)
const PATCH_LEVEL = (UInt32)(2)
# end enum libraryPropertyType_t

# begin enum libraryPropertyType
const libraryPropertyType = UInt32
const MAJOR_VERSION = (UInt32)(0)
const MINOR_VERSION = (UInt32)(1)
const PATCH_LEVEL = (UInt32)(2)
# end enum libraryPropertyType

const cudaStreamCallback_t = Ptr{Void}
# $(Expr(:typealias, :cudaStreamCallback_t, :(Ptr{Void})))

mutable struct cudnnContext
end

const cudnnHandle_t = Ptr{cudnnContext}
# $(Expr(:typealias, :cudnnHandle_t, :(Ptr{cudnnContext})))

# begin enum ANONYMOUS_1
const ANONYMOUS_1 = UInt32
const CUDNN_STATUS_SUCCESS = (UInt32)(0)
const CUDNN_STATUS_NOT_INITIALIZED = (UInt32)(1)
const CUDNN_STATUS_ALLOC_FAILED = (UInt32)(2)
const CUDNN_STATUS_BAD_PARAM = (UInt32)(3)
const CUDNN_STATUS_INTERNAL_ERROR = (UInt32)(4)
const CUDNN_STATUS_INVALID_VALUE = (UInt32)(5)
const CUDNN_STATUS_ARCH_MISMATCH = (UInt32)(6)
const CUDNN_STATUS_MAPPING_ERROR = (UInt32)(7)
const CUDNN_STATUS_EXECUTION_FAILED = (UInt32)(8)
const CUDNN_STATUS_NOT_SUPPORTED = (UInt32)(9)
const CUDNN_STATUS_LICENSE_ERROR = (UInt32)(10)
# end enum ANONYMOUS_1

# begin enum cudnnStatus_t
const cudnnStatus_t = UInt32
const CUDNN_STATUS_SUCCESS = (UInt32)(0)
const CUDNN_STATUS_NOT_INITIALIZED = (UInt32)(1)
const CUDNN_STATUS_ALLOC_FAILED = (UInt32)(2)
const CUDNN_STATUS_BAD_PARAM = (UInt32)(3)
const CUDNN_STATUS_INTERNAL_ERROR = (UInt32)(4)
const CUDNN_STATUS_INVALID_VALUE = (UInt32)(5)
const CUDNN_STATUS_ARCH_MISMATCH = (UInt32)(6)
const CUDNN_STATUS_MAPPING_ERROR = (UInt32)(7)
const CUDNN_STATUS_EXECUTION_FAILED = (UInt32)(8)
const CUDNN_STATUS_NOT_SUPPORTED = (UInt32)(9)
const CUDNN_STATUS_LICENSE_ERROR = (UInt32)(10)
# end enum cudnnStatus_t

mutable struct cudnnTensorStruct
end

const cudnnTensorDescriptor_t = Ptr{cudnnTensorStruct}
# $(Expr(:typealias, :cudnnTensorDescriptor_t, :(Ptr{cudnnTensorStruct})))

mutable struct cudnnConvolutionStruct
end

const cudnnConvolutionDescriptor_t = Ptr{cudnnConvolutionStruct}
# $(Expr(:typealias, :cudnnConvolutionDescriptor_t, :(Ptr{cudnnConvolutionStruct})))

mutable struct cudnnPoolingStruct
end

const cudnnPoolingDescriptor_t = Ptr{cudnnPoolingStruct}
# $(Expr(:typealias, :cudnnPoolingDescriptor_t, :(Ptr{cudnnPoolingStruct})))

mutable struct cudnnFilterStruct
end

const cudnnFilterDescriptor_t = Ptr{cudnnFilterStruct}
# $(Expr(:typealias, :cudnnFilterDescriptor_t, :(Ptr{cudnnFilterStruct})))

mutable struct cudnnLRNStruct
end

const cudnnLRNDescriptor_t = Ptr{cudnnLRNStruct}
# $(Expr(:typealias, :cudnnLRNDescriptor_t, :(Ptr{cudnnLRNStruct})))

mutable struct cudnnActivationStruct
end

const cudnnActivationDescriptor_t = Ptr{cudnnActivationStruct}
# $(Expr(:typealias, :cudnnActivationDescriptor_t, :(Ptr{cudnnActivationStruct})))

mutable struct cudnnSpatialTransformerStruct
end

const cudnnSpatialTransformerDescriptor_t = Ptr{cudnnSpatialTransformerStruct}
# $(Expr(:typealias, :cudnnSpatialTransformerDescriptor_t, :(Ptr{cudnnSpatialTransformerStruct})))

mutable struct cudnnOpTensorStruct
end

const cudnnOpTensorDescriptor_t = Ptr{cudnnOpTensorStruct}
# $(Expr(:typealias, :cudnnOpTensorDescriptor_t, :(Ptr{cudnnOpTensorStruct})))

# begin enum ANONYMOUS_2
const ANONYMOUS_2 = UInt32
const CUDNN_DATA_FLOAT = (UInt32)(0)
const CUDNN_DATA_DOUBLE = (UInt32)(1)
const CUDNN_DATA_HALF = (UInt32)(2)
# end enum ANONYMOUS_2

# begin enum cudnnDataType_t
const cudnnDataType_t = UInt32
const CUDNN_DATA_FLOAT = (UInt32)(0)
const CUDNN_DATA_DOUBLE = (UInt32)(1)
const CUDNN_DATA_HALF = (UInt32)(2)
# end enum cudnnDataType_t

# begin enum ANONYMOUS_3
const ANONYMOUS_3 = UInt32
const CUDNN_NOT_PROPAGATE_NAN = (UInt32)(0)
const CUDNN_PROPAGATE_NAN = (UInt32)(1)
# end enum ANONYMOUS_3

# begin enum cudnnNanPropagation_t
const cudnnNanPropagation_t = UInt32
const CUDNN_NOT_PROPAGATE_NAN = (UInt32)(0)
const CUDNN_PROPAGATE_NAN = (UInt32)(1)
# end enum cudnnNanPropagation_t

# begin enum ANONYMOUS_4
const ANONYMOUS_4 = UInt32
const CUDNN_TENSOR_NCHW = (UInt32)(0)
const CUDNN_TENSOR_NHWC = (UInt32)(1)
# end enum ANONYMOUS_4

# begin enum cudnnTensorFormat_t
const cudnnTensorFormat_t = UInt32
const CUDNN_TENSOR_NCHW = (UInt32)(0)
const CUDNN_TENSOR_NHWC = (UInt32)(1)
# end enum cudnnTensorFormat_t

# begin enum ANONYMOUS_5
const ANONYMOUS_5 = UInt32
const CUDNN_OP_TENSOR_ADD = (UInt32)(0)
const CUDNN_OP_TENSOR_MUL = (UInt32)(1)
const CUDNN_OP_TENSOR_MIN = (UInt32)(2)
const CUDNN_OP_TENSOR_MAX = (UInt32)(3)
# end enum ANONYMOUS_5

# begin enum cudnnOpTensorOp_t
const cudnnOpTensorOp_t = UInt32
const CUDNN_OP_TENSOR_ADD = (UInt32)(0)
const CUDNN_OP_TENSOR_MUL = (UInt32)(1)
const CUDNN_OP_TENSOR_MIN = (UInt32)(2)
const CUDNN_OP_TENSOR_MAX = (UInt32)(3)
# end enum cudnnOpTensorOp_t

# begin enum ANONYMOUS_6
const ANONYMOUS_6 = UInt32
const CUDNN_CONVOLUTION = (UInt32)(0)
const CUDNN_CROSS_CORRELATION = (UInt32)(1)
# end enum ANONYMOUS_6

# begin enum cudnnConvolutionMode_t
const cudnnConvolutionMode_t = UInt32
const CUDNN_CONVOLUTION = (UInt32)(0)
const CUDNN_CROSS_CORRELATION = (UInt32)(1)
# end enum cudnnConvolutionMode_t

# begin enum ANONYMOUS_7
const ANONYMOUS_7 = UInt32
const CUDNN_CONVOLUTION_FWD_NO_WORKSPACE = (UInt32)(0)
const CUDNN_CONVOLUTION_FWD_PREFER_FASTEST = (UInt32)(1)
const CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT = (UInt32)(2)
# end enum ANONYMOUS_7

# begin enum cudnnConvolutionFwdPreference_t
const cudnnConvolutionFwdPreference_t = UInt32
const CUDNN_CONVOLUTION_FWD_NO_WORKSPACE = (UInt32)(0)
const CUDNN_CONVOLUTION_FWD_PREFER_FASTEST = (UInt32)(1)
const CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT = (UInt32)(2)
# end enum cudnnConvolutionFwdPreference_t

# begin enum ANONYMOUS_8
const ANONYMOUS_8 = UInt32
const CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM = (UInt32)(0)
const CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM = (UInt32)(1)
const CUDNN_CONVOLUTION_FWD_ALGO_GEMM = (UInt32)(2)
const CUDNN_CONVOLUTION_FWD_ALGO_DIRECT = (UInt32)(3)
const CUDNN_CONVOLUTION_FWD_ALGO_FFT = (UInt32)(4)
const CUDNN_CONVOLUTION_FWD_ALGO_FFT_TILING = (UInt32)(5)
const CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD = (UInt32)(6)
const CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED = (UInt32)(7)
# end enum ANONYMOUS_8

# begin enum cudnnConvolutionFwdAlgo_t
const cudnnConvolutionFwdAlgo_t = UInt32
const CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM = (UInt32)(0)
const CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM = (UInt32)(1)
const CUDNN_CONVOLUTION_FWD_ALGO_GEMM = (UInt32)(2)
const CUDNN_CONVOLUTION_FWD_ALGO_DIRECT = (UInt32)(3)
const CUDNN_CONVOLUTION_FWD_ALGO_FFT = (UInt32)(4)
const CUDNN_CONVOLUTION_FWD_ALGO_FFT_TILING = (UInt32)(5)
const CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD = (UInt32)(6)
const CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED = (UInt32)(7)
# end enum cudnnConvolutionFwdAlgo_t

mutable struct cudnnConvolutionFwdAlgoPerf_t
    algo::cudnnConvolutionFwdAlgo_t
    status::cudnnStatus_t
    time::Cfloat
    memory::Cint
end

# begin enum ANONYMOUS_9
const ANONYMOUS_9 = UInt32
const CUDNN_CONVOLUTION_BWD_FILTER_NO_WORKSPACE = (UInt32)(0)
const CUDNN_CONVOLUTION_BWD_FILTER_PREFER_FASTEST = (UInt32)(1)
const CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT = (UInt32)(2)
# end enum ANONYMOUS_9

# begin enum cudnnConvolutionBwdFilterPreference_t
const cudnnConvolutionBwdFilterPreference_t = UInt32
const CUDNN_CONVOLUTION_BWD_FILTER_NO_WORKSPACE = (UInt32)(0)
const CUDNN_CONVOLUTION_BWD_FILTER_PREFER_FASTEST = (UInt32)(1)
const CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT = (UInt32)(2)
# end enum cudnnConvolutionBwdFilterPreference_t

# begin enum ANONYMOUS_10
const ANONYMOUS_10 = UInt32
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0 = (UInt32)(0)
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1 = (UInt32)(1)
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT = (UInt32)(2)
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_3 = (UInt32)(3)
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED = (UInt32)(5)
# end enum ANONYMOUS_10

# begin enum cudnnConvolutionBwdFilterAlgo_t
const cudnnConvolutionBwdFilterAlgo_t = UInt32
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0 = (UInt32)(0)
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1 = (UInt32)(1)
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT = (UInt32)(2)
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_3 = (UInt32)(3)
const CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED = (UInt32)(5)
# end enum cudnnConvolutionBwdFilterAlgo_t

mutable struct cudnnConvolutionBwdFilterAlgoPerf_t
    algo::cudnnConvolutionBwdFilterAlgo_t
    status::cudnnStatus_t
    time::Cfloat
    memory::Cint
end

# begin enum ANONYMOUS_11
const ANONYMOUS_11 = UInt32
const CUDNN_CONVOLUTION_BWD_DATA_NO_WORKSPACE = (UInt32)(0)
const CUDNN_CONVOLUTION_BWD_DATA_PREFER_FASTEST = (UInt32)(1)
const CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT = (UInt32)(2)
# end enum ANONYMOUS_11

# begin enum cudnnConvolutionBwdDataPreference_t
const cudnnConvolutionBwdDataPreference_t = UInt32
const CUDNN_CONVOLUTION_BWD_DATA_NO_WORKSPACE = (UInt32)(0)
const CUDNN_CONVOLUTION_BWD_DATA_PREFER_FASTEST = (UInt32)(1)
const CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT = (UInt32)(2)
# end enum cudnnConvolutionBwdDataPreference_t

# begin enum ANONYMOUS_12
const ANONYMOUS_12 = UInt32
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_0 = (UInt32)(0)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_1 = (UInt32)(1)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT = (UInt32)(2)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT_TILING = (UInt32)(3)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD = (UInt32)(4)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED = (UInt32)(5)
# end enum ANONYMOUS_12

# begin enum cudnnConvolutionBwdDataAlgo_t
const cudnnConvolutionBwdDataAlgo_t = UInt32
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_0 = (UInt32)(0)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_1 = (UInt32)(1)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT = (UInt32)(2)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT_TILING = (UInt32)(3)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD = (UInt32)(4)
const CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED = (UInt32)(5)
# end enum cudnnConvolutionBwdDataAlgo_t

mutable struct cudnnConvolutionBwdDataAlgoPerf_t
    algo::cudnnConvolutionBwdDataAlgo_t
    status::cudnnStatus_t
    time::Cfloat
    memory::Cint
end

# begin enum ANONYMOUS_13
const ANONYMOUS_13 = UInt32
const CUDNN_SOFTMAX_FAST = (UInt32)(0)
const CUDNN_SOFTMAX_ACCURATE = (UInt32)(1)
const CUDNN_SOFTMAX_LOG = (UInt32)(2)
# end enum ANONYMOUS_13

# begin enum cudnnSoftmaxAlgorithm_t
const cudnnSoftmaxAlgorithm_t = UInt32
const CUDNN_SOFTMAX_FAST = (UInt32)(0)
const CUDNN_SOFTMAX_ACCURATE = (UInt32)(1)
const CUDNN_SOFTMAX_LOG = (UInt32)(2)
# end enum cudnnSoftmaxAlgorithm_t

# begin enum ANONYMOUS_14
const ANONYMOUS_14 = UInt32
const CUDNN_SOFTMAX_MODE_INSTANCE = (UInt32)(0)
const CUDNN_SOFTMAX_MODE_CHANNEL = (UInt32)(1)
# end enum ANONYMOUS_14

# begin enum cudnnSoftmaxMode_t
const cudnnSoftmaxMode_t = UInt32
const CUDNN_SOFTMAX_MODE_INSTANCE = (UInt32)(0)
const CUDNN_SOFTMAX_MODE_CHANNEL = (UInt32)(1)
# end enum cudnnSoftmaxMode_t

# begin enum ANONYMOUS_15
const ANONYMOUS_15 = UInt32
const CUDNN_POOLING_MAX = (UInt32)(0)
const CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING = (UInt32)(1)
const CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING = (UInt32)(2)
# end enum ANONYMOUS_15

# begin enum cudnnPoolingMode_t
const cudnnPoolingMode_t = UInt32
const CUDNN_POOLING_MAX = (UInt32)(0)
const CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING = (UInt32)(1)
const CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING = (UInt32)(2)
# end enum cudnnPoolingMode_t

# begin enum ANONYMOUS_16
const ANONYMOUS_16 = UInt32
const CUDNN_ACTIVATION_SIGMOID = (UInt32)(0)
const CUDNN_ACTIVATION_RELU = (UInt32)(1)
const CUDNN_ACTIVATION_TANH = (UInt32)(2)
const CUDNN_ACTIVATION_CLIPPED_RELU = (UInt32)(3)
# end enum ANONYMOUS_16

# begin enum cudnnActivationMode_t
const cudnnActivationMode_t = UInt32
const CUDNN_ACTIVATION_SIGMOID = (UInt32)(0)
const CUDNN_ACTIVATION_RELU = (UInt32)(1)
const CUDNN_ACTIVATION_TANH = (UInt32)(2)
const CUDNN_ACTIVATION_CLIPPED_RELU = (UInt32)(3)
# end enum cudnnActivationMode_t

# begin enum ANONYMOUS_17
const ANONYMOUS_17 = UInt32
const CUDNN_LRN_CROSS_CHANNEL_DIM1 = (UInt32)(0)
# end enum ANONYMOUS_17

# begin enum cudnnLRNMode_t
const cudnnLRNMode_t = UInt32
const CUDNN_LRN_CROSS_CHANNEL_DIM1 = (UInt32)(0)
# end enum cudnnLRNMode_t

# begin enum ANONYMOUS_18
const ANONYMOUS_18 = UInt32
const CUDNN_DIVNORM_PRECOMPUTED_MEANS = (UInt32)(0)
# end enum ANONYMOUS_18

# begin enum cudnnDivNormMode_t
const cudnnDivNormMode_t = UInt32
const CUDNN_DIVNORM_PRECOMPUTED_MEANS = (UInt32)(0)
# end enum cudnnDivNormMode_t

# begin enum ANONYMOUS_19
const ANONYMOUS_19 = UInt32
const CUDNN_BATCHNORM_PER_ACTIVATION = (UInt32)(0)
const CUDNN_BATCHNORM_SPATIAL = (UInt32)(1)
# end enum ANONYMOUS_19

# begin enum cudnnBatchNormMode_t
const cudnnBatchNormMode_t = UInt32
const CUDNN_BATCHNORM_PER_ACTIVATION = (UInt32)(0)
const CUDNN_BATCHNORM_SPATIAL = (UInt32)(1)
# end enum cudnnBatchNormMode_t

# begin enum ANONYMOUS_20
const ANONYMOUS_20 = UInt32
const CUDNN_SAMPLER_BILINEAR = (UInt32)(0)
# end enum ANONYMOUS_20

# begin enum cudnnSamplerType_t
const cudnnSamplerType_t = UInt32
const CUDNN_SAMPLER_BILINEAR = (UInt32)(0)
# end enum cudnnSamplerType_t

mutable struct cudnnDropoutStruct
end

const cudnnDropoutDescriptor_t = Ptr{cudnnDropoutStruct}
# $(Expr(:typealias, :cudnnDropoutDescriptor_t, :(Ptr{cudnnDropoutStruct})))

# begin enum ANONYMOUS_21
const ANONYMOUS_21 = UInt32
const CUDNN_RNN_RELU = (UInt32)(0)
const CUDNN_RNN_TANH = (UInt32)(1)
const CUDNN_LSTM = (UInt32)(2)
const CUDNN_GRU = (UInt32)(3)
# end enum ANONYMOUS_21

# begin enum cudnnRNNMode_t
const cudnnRNNMode_t = UInt32
const CUDNN_RNN_RELU = (UInt32)(0)
const CUDNN_RNN_TANH = (UInt32)(1)
const CUDNN_LSTM = (UInt32)(2)
const CUDNN_GRU = (UInt32)(3)
# end enum cudnnRNNMode_t

# begin enum ANONYMOUS_22
const ANONYMOUS_22 = UInt32
const CUDNN_UNIDIRECTIONAL = (UInt32)(0)
const CUDNN_BIDIRECTIONAL = (UInt32)(1)
# end enum ANONYMOUS_22

# begin enum cudnnDirectionMode_t
const cudnnDirectionMode_t = UInt32
const CUDNN_UNIDIRECTIONAL = (UInt32)(0)
const CUDNN_BIDIRECTIONAL = (UInt32)(1)
# end enum cudnnDirectionMode_t

# begin enum ANONYMOUS_23
const ANONYMOUS_23 = UInt32
const CUDNN_LINEAR_INPUT = (UInt32)(0)
const CUDNN_SKIP_INPUT = (UInt32)(1)
# end enum ANONYMOUS_23

# begin enum cudnnRNNInputMode_t
const cudnnRNNInputMode_t = UInt32
const CUDNN_LINEAR_INPUT = (UInt32)(0)
const CUDNN_SKIP_INPUT = (UInt32)(1)
# end enum cudnnRNNInputMode_t

mutable struct cudnnRNNStruct
end

const cudnnRNNDescriptor_t = Ptr{cudnnRNNStruct}
# $(Expr(:typealias, :cudnnRNNDescriptor_t, :(Ptr{cudnnRNNStruct})))


text:
using Documenter # A package to manage documentation
using Literate   # A package for literate programming
using Scats      # A package to create the documentation for

# Example: input path
EXAMPLE = joinpath(@__DIR__, "..", "examples", "example.jl")

# Example: output path
OUTPUT = joinpath(@__DIR__, "src", "generated")

# Delete previously generated content if present
isdir(OUTPUT) && rm(OUTPUT, recursive = true)

# Example: generate a Markdown file and a notebook
Literate.markdown(EXAMPLE, OUTPUT)
Literate.notebook(EXAMPLE, OUTPUT)

# Create documentation
makedocs(
    # Specify modules being used
    modules = [Scats],

    # Specify a name for the site
    sitename = "Scats.jl",

    # Specify the author
    authors = "Pavel Sobolev.",

    # Specify the pages on the left side
    pages = [
        # Home page
        "Home" => "index.md",

        # Example page
        "Example" => "generated/example.md",

        # Library page
        "Library" => Any[
            # Public
            "lib/Public.md",

            # Internals
            "Internals" => map(
                s -> "lib/Internals/$(s)",
                [
                    "Module.md",
                    "Prec.md",
                    "Input.md",
                    "Result.md",
                    "Gen.md",
                    "Extras.md"
                ]
            ),
        ],
    ],

    # Specify a format
    format = Documenter.HTML(
            # Custom assets
            assets = ["assets/custom.css"],
            # A fallback for creating docs locally
            prettyurls = get(ENV, "CI", nothing) == "true",
        ),

    # Fail if any error occurred
    strict = true,
)

# Determine the path to the generated example (HTML)
EXAMPLE_PATH = joinpath(@__DIR__, "build", "generated", "example.html")
if !ispath(EXAMPLE_PATH)
    EXAMPLE_PATH = joinpath(@__DIR__, "build", "generated", "example", "index.html")
end

# Postprocessing: remove gcf() from HTML version
content = read(EXAMPLE_PATH, String)
content = replace(content, "\ngcf()" => "")

open(EXAMPLE_PATH, "w") do io
    print(io, content)
end

# Set the path to the generated example (notebook)
EXAMPLE_PATH = joinpath(@__DIR__, "build", "generated", "example.ipynb")

# Postprocessing: remove gcf() from notebook version
content = read(EXAMPLE_PATH, String)
content = replace(content, "\\n\",\n    \"gcf()\"" => "\"")
ss2 = findnext("Updating", content, 1)
ss1 = findprev("{", content, ss2.start)
ss3 = findnext("}", content, ss1.stop)
content = replace(content, content[ss1.start - 6:ss3.start + 6] => "[],")

open(EXAMPLE_PATH, "w") do io
    print(io, content)
end

# Deploy documentation
deploydocs(
    # Specify a repository
    repo = "github.com/paveloom-j/Scats.jl.git",

    # Create documentation previews for pull requests
    push_preview = true,

    # Specify a development branch
    devbranch = "develop",
)

ext: jl


text:
using .TaylorSeries, FFTW
import FFTW.fft!;

function get_diff(x::AbstractArray,n::Integer)
	return TaylorSeries.getcoeff.(differentiate.(x,n),0)
end
function fft!(x::AbstractArray{T}) where {T <: AbstractSeries{cpx}} where {cpx <: Complex{num}} where {num <: Number}
	Xcomplex=[el[0] for el in x]
    planned_fft = plan_fft!(similar(Xcomplex))
    Xcomplex .= planned_fft * Xcomplex
	idx=1:get_order(x[1])
	ders=[get_diff(x,i) for i in idx];
	for i in idx
		ders[i] .= planned_fft * ders[i]
	end
	for i in 1:length(x)
		ders2=[ders[order][i] for order in idx]
		@views x[i]=Taylor1([Xcomplex[i],ders2...])
	end
    nothing
end


text:
function Base.insert!(ll::LinkedList{T}, index::Integer, item::T) where T
    if index == 1
        if isempty(ll)
            return push!(ll, item)
        else
            ll.head = Node{T}(item, ll.head)
        end
    else
        nd = ll.head
        while index > 2
            if nd.next isa EmptyNode
                throw(BoundsError())
            else
                nd = nd.next
                index -= 1
            end
        end
        nd.next = Node{T}(item, nd.next)
    end
    return ll
end

max_stars_repo_name: ethansaxenian/RosettaDecode

max_issues_repo_name: ethansaxenian/RosettaDecode

max_forks_repo_name: ethansaxenian/RosettaDecode


text:
#=
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.

What is the sum of the digits of the number 21000?
=#
function powersum()
  x = BigInt(1000)
  sum(digits(2^x))
end
@time println(powersum())

max_stars_repo_name: daniel-beard/JuliaProjectEuler

max_issues_repo_name: daniel-beard/JuliaProjectEuler

max_forks_repo_name: daniel-beard/JuliaProjectEuler


text:
function Plhd(Pk,ks,μs; BiasOperatorDictlhd, f)
    plhd = zeros(Float64,length(ks),length(μs))
    b1 = BiasOperatorDictlhd["b1"]
    bη = BiasOperatorDictlhd["bη"]
    P0_ϵ = BiasOperatorDictlhd["P0ϵ"]
    b∇2δ = BiasOperatorDictlhd["b∇2δ"]
    β∇2v = BiasOperatorDictlhd["β∇2v"]
    β∂2parav = BiasOperatorDictlhd["β∂2∥v"]
    P2_ϵ = BiasOperatorDictlhd["P2ϵ"]
    P2_ϵε_η = BiasOperatorDictlhd["P2ϵεη"]
    for i = 1:length(μs)
        @. plhd[:,i] = (b1 - bη*f*μs[i]^2)^2*Pk(ks) + P0_ϵ -
        2*(b1*b∇2δ - μs[i]^2*f*bη*(b∇2δ + b1*β∇2v + b1*β∂2parav*μs[i]^2) +
            μs[i]^4*f^2*bη^2*(β∇2v + β∂2parav*μs[i]^2))*ks^2*Pk(ks) +
        ks^2*P2_ϵ + μs[i]^2*ks^2*bη*P2_ϵε_η
    end
    return plhd
end

function Pllhd(Pk, ks, l; BiasOperatorDictlhd, f)
    b1 = BiasOperatorDictlhd["b1"]
    bη = BiasOperatorDictlhd["bη"]
    P0_ϵ = BiasOperatorDictlhd["P0ϵ"]
    b∇2δ = BiasOperatorDictlhd["b∇2δ"]
    β∇2v = BiasOperatorDictlhd["β∇2v"]
    β∂2parav = BiasOperatorDictlhd["β∂2∥v"]
    P2_ϵ = BiasOperatorDictlhd["P2ϵ"]
    P2_ϵε_η = BiasOperatorDictlhd["P2ϵεη"]
    Pkvals = Pk.(ks)
    if l == 0
        @. b1^2*Pkvals - (2/15)b1*Pkvals*(f*bη*(-5β∇2v*ks^2 - 3β∂2parav*ks^2 + 5) + 15b∇2δ*ks^2) -
            (1/35)f^2*Pkvals*bη^2*(14β∇2v*ks^2 + 10β∂2parav*ks^2 - 7) +
            (1/3)ks^2*bη*(2b∇2δ*f*Pkvals + P2_ϵε_η) + ks^2*P2_ϵ + P0_ϵ
    elseif l == 2
        @. (2/21)bη*(2*f*Pkvals*(f*bη*(3-ks^2*(6β∇2v+5β∂2parav))+b1*(ks^2*(7β∇2v + 6β∂2parav) - 7)) +
            7ks^2*(2b∇2δ*f*Pkvals + P2_ϵε_η))
    elseif l == 4
        @. -(8/385)f*Pkvals*bη*(f*bη*(22β∇2v*ks^2 + 30β∂2parav*ks^2 - 11) - 22b1*β∂2parav*ks^2)
    elseif l == 6
        @. -(32/231)β∂2parav*f^2*ks^2*Pkvals*bη^2
    else
        fill!(similar(ks), 0)
    end
end

function Plhdmultipole(Pk, ks, μs; BiasOperatorDictlhd, f)
    L(n,x) = Legendre(n,x)
    Pl = l -> Pllhd(Pk, ks, l, BiasOperatorDictlhd=BiasOperatorDictlhd, f=f)
    P0 = Pl(0)
    P2 = Pl(2)
    P4 = Pl(4)
    P6 = Pl(6)
    plhdmp = Array{Float64}(undef, length(ks), length(μs))
    for i = 1:length(μs)
        @. plhdmp[:,i] = L(0,μs[i])*P0 + L(2,μs[i])*P2 + L(4,μs[i])*P4 + L(6,μs[i])*P6
    end
    return plhdmp
end

max_stars_repo_name: JosephTomlinson/GeneralBiasPk

max_issues_repo_name: JosephTomlinson/GeneralBiasPk

max_forks_repo_name: JosephTomlinson/GeneralBiasPk


text:
module PkgMassInstaller

import Pkg
import Pkg.TOML
import ArgParse

export install_projs, install_projs_args

include("utils.jl")
include("install_projs.jl")
include("install_projs_args.jl")

end


text:
using BinaryProvider
using CMakeWrapper: cmake_executable
using Libdl: dlext

function compile(libname, tarball_url, hash; prefix=BinaryProvider.global_prefix, verbose=false)
    # download to tarball_path
    tarball_path = joinpath(prefix, "downloads", "src.tar.gz")
    download_verify(tarball_url, hash, tarball_path; force=true, verbose=verbose)

    # unpack into source_path
    tarball_dir = joinpath(prefix, "downloads", dirname(first(list_tarball_files(tarball_path)))) # e.g. "nlopt-2.4.2"
    source_path = joinpath(prefix, "downloads", "src")
    verbose && @info("Unpacking $tarball_path into $source_path")
    rm(tarball_dir, force=true, recursive=true)
    rm(source_path, force=true, recursive=true)
    unpack(tarball_path, dirname(tarball_dir); verbose=verbose)
    mv(tarball_dir, source_path)

    build_dir = joinpath(source_path, "build")
    mkdir(build_dir)
    verbose && @info("Compiling in $build_dir...")
    cd(build_dir) do
        run(`$cmake_executable -DNLOPT_CXX=On -DNLOPT_PYTHON=Off -DNLOPT_OCTAVE=Off -DNLOPT_MATLAB=Off -DNLOPT_GUILE=Off -DNLOPT_SWIG=Off -DNLOPT_LINK_PYTHON=Off ..`)
        run(`$cmake_executable --build .`)
        mkpath(libdir(prefix))
        cp("libnlopt_cxx.$dlext", joinpath(libdir(prefix), libname*"."*dlext),
           force=true, follow_symlinks=true)
    end
end


text:
using Pkg; Pkg.activate("..")
using OceanTurb, OceanTurb.Diffusion, LinearAlgebra

@use_pyplot_utils

# First, we define the model.
model = Diffusion.Model(N=100, H=π/2, K=1.0, stepper=:ForwardEuler)
z = model.grid.zc

c_init(z) = cos(2z)
c_ans(z, t) = exp(-4t) * c_init(z)

function c_err(model, dt, nt=1)
    model.solution.c = c_init
    reset!(model.clock)
    time_step!(model, dt, nt)
    norm(c_ans.(z, model.clock.time) .- data(model.solution.c))
end

dt = 0.001:0.0001:0.1
errors = similar(dt)

for i in 1:length(dt)
    errors[i] = c_err(model, dt[i])
end

# Initialize plotting
ax, fig = subplots()
xlabel("error")
ylabel(L"z")
cornerspines()

plot(dt, errors, "-", label="Measured error")
plot(dt, dt.^2, "k--", label=L"\Delta t^2")

yscale("log")
xscale("log")
legend()
gcf()


text:
#Script para migrar información de las series de tiempo conjeturadas a la tabla CTD
using  CSV, DataFrames, Dates

abreviaturas_entidades = ["AGU", "BCN", "BCS", "CAM", "CHP", "CHH", "CMX", "COA", "COL", "DUR", "GUA", "GRO", "HID", "JAL", "MIC", "MOR", "MEX", "NAY", "NLE", "OAX", "PUE", "QUE", "ROO", "SLP", "SIN", "SON", "TAB", "TAM", "TLA", "VER", "YUC", "ZAC"]

#Cálculo de los números de tipos de casos por estado a partir de las series de tiempo conjeturadas para construir la tabla resumen.
function tipo_casos(datos, abreviatura_estado)

    #El número total de casos sospechosos en el estado:
    sospechosos = datos[!, Symbol(abreviatura_estado*"_S")][end]
    #El número total de casos confirmados en el estado:
    positivos = datos[!, Symbol(abreviatura_estado*"_P")][end]
    #El número total de casos confirmados fallecidos en el estado:
    fallecidos = datos[!, Symbol(abreviatura_estado*"_PF")][end]

    return [sospechosos, missing, missing, positivos, missing, fallecidos]
end

#Actualiza la tabla cumulativa del día a partir de la fecha y los datos de las series de tiempo conjeturadas.
function fila_actualización()

    if Time(now()) < Time(19)
        fecha = today() - Day(1)
    else
        fecha = today()
    end

    fecha_string = Dates.format(fecha, "yyyymmdd")

    #Cargamos las series de tiempo
    datos = CSV.read("Open_data/Time_series/$(fecha_string[1:6])/Mexico_COVID19_$fecha_string.csv", header = 1, DataFrame)

    #Calcula los casos de cada estado
    casos_estados = map(estado -> tipo_casos(datos, estado), abreviaturas_entidades)

    #Calcula los casos en el país
    acumulado_país = sum(casos_estados)

    #Calcula el número total de muestras analizadas.
    total_tests = acumulado_país[4] + missing
    #Genera un vector con el número de casos positivos importados, locales, total de casos; positivos reportados, sospechosos reportados, negativos reportados, número total de pruebas, número de casos recuperados y número de casos fallecidos (para mantener el orden de la tabla original):
    reporte_país = [acumulado_país[1:4]..., missing, missing, missing, missing, total_tests, acumulado_país[5:6]...]

    #Genera la fila de datos del día correspondiente:
    fila = string.(vcat(casos_estados..., reporte_país))

    #Agrega la fecha a la primer columna:
    pushfirst!(fila, string(fecha))

    #Agrega comas para el csv y lo junta todo en un string
    fila_csv = prod(fila[1:(end - 1)].*",")*fila[end]

    #Elimina los missing (para que quede el espacio vacío)
    fila_csv = replace(fila_csv, r"missing" => "")

    #Agrega el resultado al csv acumulativo:
    open("Mexico_COVID19_CTD.csv", "a") do io

        write(io, fila_csv*"\n")
    end

    return "Done"
end

fila_actualización()


text:
module RANSACVisualizer

using LinearAlgebra

using AbstractPlotting: Point3f0, legend
# using AbstractPlotting: Face
# using AbstractPlotting
using Makie: scatter, linesegments!, Scene, scatter!, lines, arrows!, wireframe, lines!, vbox
using Makie: mesh!, cam3d!, Sphere, Point
using GeometryTypes: Cylinder, Circle, HomogenousMesh, vertices, normals
using RANSAC
using StaticArrays
using ColorSchemes

# for cone
# using Makie
# using GeometryTypes

export  showgeometry,
        showgeometry!,
        showcandlength,
        showshapes,
        showshapes!,
        getrest,
        showtype,
        showbytype,
        showbytype!,
        plotshape,
        plotshape!,
        drawcircles!,
        wframe,
        plotspantree!,
        givelargest

# export  ConeMesh

include("visualizations.jl")
include("api.jl")
#include("cone3.jl")

end # module


text:
module CylinderModel

using GridapGmsh
using Gridap.Io
to_json_file(GmshDiscreteModel("mesh.msh"),"mesh.json")

end


text:
using RandomProcesses

d = CRT(100, 0.01)
x = rand(d)

d = CRT(100, 1.0)
x = rand(d)


text:
# NE - run base case results
push!(LOAD_PATH, joinpath(ENV["REPO_PATH"], "Sesi.jl/src"))

using CSV
using JuMP
using IterTools
using JSON
using DataFrames

import Sesi # import vs using so I can reload this from the REPL

include("jl_utils.jl")

save = false
verb = true

folderIn = joinpath(ENV["REPO_PATH"], "data/jl_in/")
folderOut = joinpath(ENV["REPO_PATH"], "data/jl_out/")

fileNm = folderIn * "jlInput.csv"

if verb
    println(repeat("#",80))
    println("Starting base case")
    println(repeat("#",80))
end

# Build JuMP model
sesi, p, f = build_model(fileNm; verb=false, startDate=Date(2016,1,1),
    endDate=Date(2016,12,31))

# Solve JuMP model
status = solve(sesi)
println(status)

if status == :Optimal

if save
    Sesi.save_data(sesi, f, p, folderOut * "base")
end
end

max_stars_repo_name: jdechalendar/sesi

max_issues_repo_name: jdechalendar/sesi

max_forks_repo_name: jdechalendar/sesi


text:
module ThreadsXBenchmarks

import JSON
using ArgCheck: @argcheck
using BangBang
using InteractiveUtils: versioninfo
using Logging: current_logger
using ThreadsX

const setup_terminalloggers = """
let Logging =
        Base.require(Base.PkgId(Base.UUID(0x56ddb016857b54e1b83ddb4d58db5568), "Logging")),
    TerminalLoggers = Base.require(Base.PkgId(
        Base.UUID(0x5d786b921e484d6f91516b4477ca9bed),
        "TerminalLoggers",
    ))

    Logging.global_logger(TerminalLoggers.TerminalLogger())
end
"""

is_using_terminal_logger() =
    Base.PkgId(parentmodule(typeof(current_logger()))).uuid ==
    Base.UUID(0x5d786b921e484d6f91516b4477ca9bed)

function runscript(
    script::AbstractString,
    ARGS::AbstractVector{<:AbstractString};
    env = nothing,
)
    @argcheck isfile(script)
    code = """
    $(Base.load_path_setup_code())
    $(is_using_terminal_logger() ? setup_terminalloggers : "")
    let script = popfirst!(ARGS)
        @eval Base PROGRAM_FILE = \$script
        include(script)
    end
    """
    cmd = `$(Base.julia_cmd()) --startup-file=no`
    if Base.have_color
        cmd = `$cmd --color=yes`
    end
    cmd = `$cmd -e $code $script $ARGS`
    if env !== nothing
        fullenv = copy(ENV)
        for (k, v) in env
            fullenv[k] = convert(String, v)
        end
        cmd = setenv(cmd, fullenv)
    end
    run(cmd)
end

function physical_cores()
    lines = split(read(`lscpu --parse`, String), "\n", keepempty = false)
    rows = [map(strip, split(ln, ",")) for ln in lines if !startswith(ln, "#")]
    return length(Set(r[2] for r in rows))
end

function run_nthreads(
    outdir::AbstractString;
    nthreads_range::AbstractVector{<:Integer} = 1:physical_cores(),
)
    @info "Measuring scaling with respect to number of threads"

    mkpath(outdir)
    open(versioninfo, joinpath(outdir, "versioninfo.txt"), write = true)

    scriptdir = joinpath(@__DIR__, "scripts")

    @info "Running: `scaling_nthreads_baseline.jl`"
    runscript(
        joinpath(scriptdir, "scaling_nthreads_baseline.jl"),
        [joinpath(outdir, "scaling_nthreads_baseline")],
        env = ["JULIA_NUM_THREADS" => "1"],
    )

    for nthreads in nthreads_range
        outputstem = joinpath(outdir, "scaling_nthreads-$nthreads")
        @info "Running: `scaling_nthreads_target.jl` with $nthreads thread(s)"
        runscript(
            joinpath(scriptdir, "scaling_nthreads_target.jl"),
            [outputstem];
            env = ["JULIA_NUM_THREADS" => string(nthreads)],
        )
    end
    return
end

function run_datasize(outdir::AbstractString; nthreads::Integer = physical_cores())
    @info "Measuring scaling with respect to data size"

    mkpath(outdir)
    open(versioninfo, joinpath(outdir, "versioninfo.txt"), write = true)

    @info "Running: `scaling_datasize.jl`"
    scriptdir = joinpath(@__DIR__, "scripts")
    runscript(
        joinpath(scriptdir, "scaling_datasize.jl"),
        [joinpath(outdir, "scaling_datasize")],
        env = ["JULIA_NUM_THREADS" => string(nthreads)],
    )
    return
end

function run_all(
    outdir::AbstractString;
    nthreads_range::AbstractVector{<:Integer} = 1:physical_cores(),
    default_nthreads::Integer = maximum(nthreads_range),
)
    run_nthreads(outdir; nthreads_range = nthreads_range)
    # run_datasize(outdir; nthreads = default_nthreads)
    return
end

include("loading.jl")

end # module


text:
using SFML

recorder = SoundBufferRecorder()

start(recorder)
println("Recording for the next 4 seconds")

sleep(4)

stop(recorder)
println("Done recording")
sound = Sound(get_buffer(recorder))
play(sound)
println("Playing")

while get_status(sound) == SoundStatus.PLAYING
end

println("Done")


text:
#InspectDR: Base functionnality and types
#-------------------------------------------------------------------------------

#AnnotationArea
#TODO: Themes: Vector/Dict of PlotLayout/MultiplotLayout?

#==Abstracts
===============================================================================#
abstract type Plot end
abstract type PlotCanvas end #TODO: Does not appear useful
abstract type PlotAnnotation end

#==Plot-level structures
===============================================================================#
#=Input structures are high-level constructs describing the plot.  They will
be broken down to lower-level structures later on.
=#

#Specifies whether plot should apply F1 acceleration to drop points:
mutable struct PointDropMatrix
	m::Array{Bool,2} #Indices: (has_line, has_glyph)
end
droppoints(m::PointDropMatrix, has_line::Bool, has_glyph::Bool) =
	m.m[has_line+1, has_glyph+1]

#Don't want immutable like LineStyle (modified by user):
mutable struct LineAttributes <: AttributeList
	style
	width #[0, 10]
	color
end
line(;style=:solid, width=1, color=COLOR_BLACK) =
	LineAttributes(style, width, color)
LineStyle(a::LineAttributes) = LineStyle(a.style, Float64(a.width), a.color)

#"line" constructor:
#TODO: Inadequate
#eval(genexpr_attriblistbuilder(:line, LineAttributes, reqfieldcnt=0))

mutable struct AreaAttributes #<: AttributeList
	line::LineAttributes
	fillcolor::Colorant
end
AreaAttributes(;line=InspectDR.line(style=:none), fillcolor=COLOR_TRANSPARENT) =
	AreaAttributes(line, fillcolor)

mutable struct GlyphAttributes <: AttributeList #Don't use "Symbol" - name used by Julia
#==IMPORTANT:
Edge width & color taken from LineAttributes
==#
	shape #because "type" is reserved
	size #of glyph.  edge width taken from LineAttributes
	color #glyph linecolor. = nothing to match line.color
	fillcolor
end
glyph(;shape=:none, size=3, color=nothing, fillcolor=nothing) =
	GlyphAttributes(shape, size, color, fillcolor)

#"glyph" constructor:
#TODO: Inadequate
#eval(genexpr_attriblistbuilder(:glyph, GlyphAttributes, reqfieldcnt=0))

mutable struct Waveform{T}
	id::String
	ds::T
	line::LineAttributes
	glyph::GlyphAttributes
	ext::PExtents2D
	strip::UInt8 #Y-strip
	visible::Bool
end

#Input waveform:
const IWaveform = Waveform{IDataset}

#Display waveform (concrete (x, y) pair):
const DWaveform = Waveform{Vector{Point2D}}

#=TODO:
typealias DWaveformCplx Waveform{PointComplex}
to track x-values of complex data??
=#

mutable struct Annotation
	title::String
	xlabel::String
	ylabels::Vector{String}
	timestamp::String
end
Annotation(;title="") = Annotation(title, "", [], Libc.strftime(time()))

mutable struct Font <: AbstractStyle
	name::String
	_size::Float64
	bold::Bool
	color::Colorant
end
Font(name::String, _size::Real; bold::Bool=false, color=COLOR_BLACK) =
	Font(name, _size, bold, color)
Font() = Font(DEFAULT_FONTNAME, 10)
function Font(ref::Font; name=StyleDefault, _size=StyleDefault, bold=StyleDefault, color=StyleDefault)
	result = deepcopy(ref)
	result[:name] = name
	result[:_size] = _size
	result[:bold] = bold
	result[:color] = color
	return result
end

mutable struct PlotLayout <: AbstractStyle #Layout/LegendLStyle
	enable_legend::Bool
	enable_timestamp::Bool

	valloc_data::Float64 #Suggested height of data (graph) area when exporting.
	valloc_top::Float64 #Top of plot data area
	valloc_mid::Float64 #Space betwen strips
	valloc_bottom::Float64 #Bottom of plot data area
	valloc_legenditemsp::Float64 #Spacing between items (% of text height).

	halloc_data::Float64 #Suggested width of data (graph) area when exporting.
	halloc_left::Float64 #Left of data area
	halloc_right::Float64 #Right of data area - excluding legend area
	#NOTE: halloc_right needs room for axis scale (ex: ×10⁻²).
	halloc_legend::Float64
	halloc_legendlineseg::Float64 #length of line segment to display.

	#Offsets to center of text:
	voffset_title::Float64
	voffset_xaxislabel::Float64 #Centered
	voffset_xticklabel::Float64

	hoffset_yaxislabel::Float64 #Centered
	hoffset_yticklabel::Float64
	hoffset_legendtext::Float64 #Spacing between line/symbol and label (% of M character).

	length_tickmajor::Float64
	length_tickminor::Float64

	line_gridmajor::LineStyle
	line_gridminor::LineStyle
	line_smithmajor::LineStyle
	line_smithminor::LineStyle

	font_title::Font
	font_axislabel::Font
	font_ticklabel::Font
	font_annotation::Font
	font_time::Font #Timestamp
	font_legend::Font

	format_xtick::TickLabelStyle
	format_ytick::TickLabelStyle

	frame_canvas::AreaAttributes #Area under entire plot
	frame_data::AreaAttributes
	frame_legend::AreaAttributes

#=TODO:
 - Legend position (left/right/...)
 - Legend autosize (auto-compute from text)
=#
end

PlotLayout() = PlotLayout(
	false, false, #enable
	0, 0, 0, 0, 0, #valloc
	0, 0, 0, 0, 0, #halloc
	0, 0, 0, #voffset
	0, 0, 0, #hoffset
	Float64(5), Float64(3), #length_tick*
	LineStyle(:dash, Float64(2), RGB24(.7, .7, .7)), #line_gridmajor
	LineStyle(:dash, Float64(1), RGB24(.7, .7, .7)), #line_gridminor
	LineStyle(:solid, Float64(2), COLOR_BLACK), #line_smithmajor
	LineStyle(:solid, Float64(1), RGB24(.7, .7, .7)), #line_smithminor
	Font(), Font(), Font(), Font(), Font(), Font(),
	TickLabelStyle(), TickLabelStyle(),
	AreaAttributes(), AreaAttributes(), AreaAttributes()
)

const PlotStyle = StyleType{PlotLayout}

#AnnotationGroup: Allows for hierarchical groupings of PlotAnnotation:
mutable struct AnnotationGroup{T<:PlotAnnotation} <: PlotAnnotation
	elem::Vector{T}
end

mutable struct TextAnnotation <: PlotAnnotation
	text::String
	pos::Pos2DOffset
	font::Font
	angle::DReal #Degrees
	align::Symbol #tl, tc, tr, cl, cc, cr, bl, bc, br
	strip::UInt8
end
#Don't use "text"... high probability of collisions when exported...
atext(text::String; x=DNaN, y=DNaN,
	xoffset_rel=0, yoffset_rel=0, xoffset=0, yoffset=0,
	font=Font(10), angle=0, align=:bl, strip=1) =
	TextAnnotation(text,
		Pos2DOffset(Point2D(x,y), Vector2D(xoffset_rel, yoffset_rel), Vector2D(xoffset, yoffset)),
		font, angle, align, strip
	)

mutable struct HVMarker <: PlotAnnotation
	vmarker::Bool
	hmarker::Bool
	pos::Point2D
	line::LineAttributes
	strip::UInt8
end
vmarker(pos, line=InspectDR.line(); strip=0) = HVMarker(true, false, Point2D(pos, DNaN), line, strip)
hmarker(pos, line=InspectDR.line(); strip=1) = HVMarker(false, true, Point2D(DNaN, pos), line, strip)
hvmarker(pos, line=InspectDR.line(); strip=1) = HVMarker(true, true, pos, line, strip)

mutable struct PolylineAnnotation <: PlotAnnotation
	#TODO: preferable to use Point2D?
	x::Vector{DReal}
	y::Vector{DReal}
	line::LineAttributes
	fillcolor::Colorant
	closepath::Bool
	strip::UInt8
end
PolylineAnnotation(x, y; line=InspectDR.line(), fillcolor=COLOR_TRANSPARENT, closepath=true, strip=1) =
	PolylineAnnotation(x, y, line, fillcolor, closepath, strip)

#Single graph strip of a Plot2D (shared x-coord):
mutable struct GraphStrip
	yscale::AxisScale
	ext_data::PExtents2D #Maximum extents of data in strip (typically all finite)
	yext_full::PExtents1D #y-extents when zoomed out to "full" (NaN values: use ext_data)
	yext::PExtents1D #Current/active y-extents (typically all finite)
	grid::PlotGrid
end
GraphStrip() = GraphStrip(AxisScale(:lin, tgtmajor=8, tgtminor=2),
	PExtents2D(), PExtents1D(), PExtents1D(),
	GridRect(vmajor=true, vminor=false, hmajor=true, hminor=false))

#2D plot.
mutable struct Plot2D <: Plot
	xscale::AxisScale
	layout::PlotStyle
	annotation::Annotation

	#Plot extents (access using getextents):
	xext_data::PExtents1D #Maximum x-extents of data in strip (typically all finite)
	xext_full::PExtents1D #x-extents when zoomed out to "full" (NaN values: use xext_data)
	xext::PExtents1D #Current/active x-extents (typically all finite)

	plotbb::NullOr{BoundingBox} #User can specify where to draw on Multiplot

	strips::Vector{GraphStrip}
	data::Vector{IWaveform}

	#Annotation controlled directly by user (using _add interface):
	userannot::Vector{PlotAnnotation}

	#Annotation controlled by parent object
	parentannot::Vector{PlotAnnotation}

	#Display data cache:
	invalid_ddata::Bool #Is cache of display data invalid?
	display_data::Vector{DWaveform} #Clipped to current extents

	displayNaN::Bool #Costly (time) on large datasets
	pointdropmatrix::PointDropMatrix

	#Maximum # of x-pts in display:
	#TODO: move to layout?
	xres::Int
end

Plot2D(;title="") = Plot2D(AxisScale(:lin, tgtmajor=3.5, tgtminor=4),
	StyleType(defaults.plotlayout), Annotation(title=title),
	PExtents1D(), PExtents1D(), PExtents1D(),
	nothing, [GraphStrip()], [], [], [], true, [],
	false, defaults.pointdropmatrix, 1000
)

#Style info for multi-plot object:
mutable struct MultiplotLayout <: AbstractStyle
	ncolumns::Int

	valloc_title::Float64 #Title height allocation (title gets centered)
	valloc_plot::Float64 #Default height for single plot when saving multi-plot
	halloc_plot::Float64 #Default width for single plot when saving multi-plot

	font_title::Font
	frame::AreaAttributes
end
MultiplotLayout() = MultiplotLayout(
	1,
	0, 0, 0, #h/valloc
	Font(),
	AreaAttributes()
)

const MultiplotStyle = StyleType{MultiplotLayout}

mutable struct Multiplot
	title::String
	subplots::Vector{Plot}
	layout::MultiplotStyle
end
#TODO: ok to deprecate titlefont=??
function Multiplot(;style::MultiplotLayout=defaults.mplotlayout, title="",
		ncolumns=StyleDefault, valloc_plot=StyleDefault, halloc_plot=StyleDefault)
	layout = StyleType(style)
	layout[:ncolumns] = ncolumns
	layout[:valloc_plot] = valloc_plot
	layout[:halloc_plot] = halloc_plot
	return Multiplot(title, [], layout)
end

#==Constructor-like functions
===============================================================================#

#==Accessors
===============================================================================#
getextents(d::IWaveform) = getextents(d.ds)
function getextents(dlist::Vector{IWaveform}, strip::Int=1)
	result = PExtents2D(DNaN, DNaN, DNaN, DNaN)
	for d in dlist
		if strip == d.strip
			result = union(result, d.ext)
		end
	end
	return result
end

hasline(w::Waveform) = (w.line.style != :none)
hasglyph(w::Waveform) = isglyph(w.glyph.shape)

#==Mutators
===============================================================================#
settitle(mplot::Plot2D, title::String) =
	(mplot.annotation.title = String(title))

settitle(mplot::Multiplot, title::String) =
	(mplot.title = String(title))

#=="add" interface
===============================================================================#

function _add(mp::Multiplot, plot::Plot2D)
	push!(mp.subplots, plot)
	return plot
end
_add(mp::Multiplot, ::Type{T}) where T<:Plot = _add(mp, T())

#Set dataf1=false to overwrite optimizations for functions of 1 argument.
function _add(plot::Plot2D, x::Vector, y::Vector; id::String="", dataf1=true, strip=1, visible=true)
	if dataf1
		dataf1 = isincreasing(x) #Can we use optimizations?
	end
	ext = PExtents2D() #Don't care at the moment
	ds = IWaveform(id, IDataset{dataf1}(x, y), line(), glyph(), ext, strip, visible)
	push!(plot.data, ds)
	return ds
end

function _add(plot::Plot2D, annot::PlotAnnotation)
	push!(plot.userannot, annot)
	return annot
end

#==Plot extents
===============================================================================#

function invalidate_extents(plot::Plot2D)
	#If extents are no longer valid, neither is display cache:
	plot.invalid_ddata = true
end

function invalidate_datalist(plot::Plot2D)
	plot.invalid_ddata = true
end

#Get/set functions for graph extents:
#-------------------------------------------------------------------------------
#Full extents are always merged (ext_full expected to be incomplete):
getxextents_full(plot::Plot2D) = merge(plot.xext_data, plot.xext_full)
getyextents_full(strip::GraphStrip) = merge(yvalues(strip.ext_data), strip.yext_full)

#Active extents:
#(Obtain values from full extents when supplied ext contains NaN fields):
#NOTE: no need for get functions.. simply access structures directly.
_setxextents(plot::Plot2D, ext::PExtents1D) =
	(plot.xext = merge(getxextents_full(plot), ext))
_setyextents(strip::GraphStrip, ext::PExtents1D) =
	(strip.yext = merge(getyextents_full(strip), ext))

function setyextents(plot::Plot2D, ext::PExtents1D, strip::Int = 1)
	_setyextents(plot.strips[strip], ext)
	#No need to invalidate... data reduction depends on x extents
	#invalidate_extents(plot)
end
function setxextents(plot::Plot2D, ext::PExtents1D)
	_setxextents(plot, ext)
	invalidate_extents(plot)
end

#NOTE: set/get*extents_axis functions: set/get extents in axis coordinates
#      (stored in user-"read"-able coordinates).
getxextents_axis(plot::Plot2D) = read2axis(plot.xext, InputXfrm1D(plot.xscale))
getyextents_axis(strip::GraphStrip) = read2axis(strip.yext, InputXfrm1D(strip.yscale))
getyextents_axis(plot::Plot2D, strip::Int) = getyextents_axis(plot.strips[strip])
getextents_axis(plot::Plot2D, strip::Int) =
	PExtents2D(getxextents_axis(plot), getyextents_axis(plot.strips[strip]))

setxextents_axis(plot::Plot2D, ext::PExtents1D) =
	setxextents(plot, axis2read(ext, InputXfrm1D(plot.xscale)))
setyextents_axis(plot::Plot2D, ext::PExtents1D, strip::Int) =
	setyextents(plot, axis2read(ext, InputXfrm1D(plot.strips[strip].yscale)), strip)
function setextents_axis(plot::Plot2D, ext::PExtents2D, strip::Int)
	setxextents_axis(plot, xvalues(ext))
	setyextents_axis(plot, yvalues(ext), strip)
end

#==Plot/graph bounding boxes
===============================================================================#

#TODO: Move aspect_square functionality to graph (not data area)
aspect_square(::PlotGrid) = false
aspect_square(::GridSmith) = true

#TODO: Deprecate this strange hack:
function grid1(plot::Plot2D)
	if length(plot.strips) > 0
		return plot.strips[1].grid
	else
		return GridRect()
	end
end

#Returns a centered bounding box with square aspect ratio.
#TODO: use in graphbounds - not databounds
function squarebounds(bb::BoundingBox)
	w = width(bb); h = height(bb)
	xmin = bb.xmin; xmax = bb.xmax
	ymin = bb.ymin; ymax = bb.ymax
	if w < h
		hdim = w / 2
		c = (ymin + ymax) / 2
		ymin = c - hdim; ymax = c + hdim
	else
		hdim = h / 2
		c = (xmin + xmax) / 2
		xmin = c - hdim; xmax = c + hdim
	end
	return BoundingBox(xmin, xmax, ymin, ymax)
end

#Get bounding box of plot data area:
function databounds(plotb::BoundingBox, lyt::PlotLayout)
	xmin = plotb.xmin + lyt.halloc_left
	xmax = plotb.xmax
	xmax -= lyt.enable_legend ? lyt.halloc_legend : lyt.halloc_right
	ymin = plotb.ymin + lyt.valloc_top
	ymax = plotb.ymax - lyt.valloc_bottom

	#Avoid division by zero, inversions, ...
	if xmin >= xmax
		c = (xmin + xmax)/2
		xmin = c - 0.5
		xmax = c + 0.5
	end
	if ymin >= ymax
		c = (ymin + ymax)/2
		ymin = c - 0.5
		ymax = c + 0.5
	end

	return BoundingBox(xmin, xmax, ymin, ymax)
end

#TODO: Move aspect_square to graphbounds.
function databounds(plotb::BoundingBox, lyt::PlotLayout, grid::PlotGrid)
	graphbb = databounds(plotb, lyt)
	if aspect_square(grid)
		graphbb = squarebounds(graphbb)
	end
	return graphbb
end

#Compute graph height (given n strips)
#TODO: Causes graphs to start/end on fractional pixels... behaves poorly.
#TODO: Latch to integer pixel boundaries.
function graph_h(datab::BoundingBox, gap::Float64, nstrips::Int)
	h = height(datab)
	if nstrips > 1
		h = (h - gap*(nstrips-1)) / nstrips
	end
	return max(h, 0)
end

#Get bounding box of graph "istrip":
function _graphbounds(datab::BoundingBox, h::Float64, pitch::Float64, istrip::Int)
	ymin = datab.ymin + pitch*(istrip-1)
	ymax = ymin + h
	return BoundingBox(datab.xmin, datab.xmax, ymin, ymax)
end

function graphbounds(datab::BoundingBox, lyt::PlotLayout, nstrips::Int, istrip::Int)
	gap = lyt.valloc_mid
	h = graph_h(datab, gap, nstrips)
	return _graphbounds(datab, h, h+gap, istrip)
end

#Get vector of graphbounds:
function graphbounds_list(datab::BoundingBox, lyt::PlotLayout, nstrips::Int)
	result = Vector{BoundingBox}(undef, nstrips)
	gap = lyt.valloc_mid
	h = graph_h(datab, gap, nstrips)
	pitch = h+gap

	for i in 1:nstrips
		result[i] = _graphbounds(datab, h, pitch, i)
	end
	return result
end

#Get bounding box of entire plot:
function plotbounds(lyt::PlotLayout, graphbb::BoundingBox)
	xmin = graphbb.xmin - lyt.halloc_left
	xmax = graphbb.xmax
	xmax += lyt.enable_legend ? lyt.halloc_legend : lyt.halloc_right
	ymin = graphbb.ymin - lyt.valloc_top
	ymax = graphbb.ymax + lyt.valloc_bottom
	return BoundingBox(xmin, xmax, ymin, ymax)
end

function plotbounds(lyt::PlotLayout, graphw::Float64, graphh::Float64)
	bb = plotbounds(lyt, BoundingBox(0, graphw, 0, graphh))
	return BoundingBox(0, width(bb), 0, height(bb))
end

#Get suggested plot bounds:
function plotbounds(lyt::PlotLayout, grid::PlotGrid)
	graphw = lyt.halloc_data; graphh = lyt.valloc_data
	if aspect_square(grid)
		graphw = graphh = min(graphw, graphh)
	end
	return plotbounds(lyt, graphw, graphh)
end

#Grid dimensions using Multiplot auto layout
function griddims_auto(mplot::Multiplot)
	nplots = length(mplot.subplots)
	ncols = mplot.layout.values.ncolumns
	nrows = div(nplots-1, ncols) + 1
	return (nrows, ncols)
end

#Computes suggested canvas size for a Multiplot object
function size_auto(mplot::Multiplot)
	#TODO: Compute more accurate size from Plot2D.plotbb
	nrows, ncols = griddims_auto(mplot)
	yoffset = mplot.layout.values.valloc_title
	w = Float64(mplot.layout.values.halloc_plot*ncols)
	h = Float64(mplot.layout.values.valloc_plot*nrows+yoffset)
	return (w, h)
end

#==Pre-processing display data
===============================================================================#

function _reduce(input::IWaveform, xext::PExtents1D, pdm::PointDropMatrix, xres_max::Integer)
	ds = droppoints(pdm, hasline(input), hasglyph(input)) ?
		_reduce(input.ds, xext, xres_max) : _reduce_nodrop(input.ds, xext, xres_max)

	return DWaveform(input.id, ds, input.line, input.glyph, input.ext, input.strip, input.visible)
end

_reduce(inputlist::Vector{IWaveform}, xext::PExtents1D, pdm::PointDropMatrix, xres_max::Integer) =
	map((input)->_reduce(input, xext, pdm, xres_max), inputlist)

#Rescale input dataset:
#-------------------------------------------------------------------------------

map2axis(input::T, x::InputXfrm1DSpec, y::InputXfrm1DSpec) where T<:IDataset =
	T(map2axis(input.x, x), map2axis(input.y, y))

function map2axis(input::IWaveform, x::InputXfrm1DSpec, y::InputXfrm1DSpec)
	ds = map2axis(input.ds, x, y)
	return IWaveform(input.id, ds, input.line, input.glyph, getextents(ds), input.strip, input.visible)
end

function map2axis(inputlist::Vector{IWaveform}, xflist::Vector{InputXfrm2D})
	n = length(inputlist) #WANTCONST
	nstrips = length(xflist) #WANTCONST
	emptyds = IDataset{true}([], []) #WANTCONST
	result = Vector{IWaveform}()

	for i in 1:n
		input = inputlist[i]
		if !input.visible; continue; end #Don't process non-visible waveforms
		strip = input.strip
		if strip > 0 && strip <= nstrips
			wfrm = map2axis(input, xflist[strip].x, xflist[strip].y)
		else #No scale for this strip... return empty waveform
			wfrm = IWaveform(input.id, emptyds, input.line, input.glyph, PExtents2D(), strip, input.visible)
		end
		push!(result, wfrm)
	end
	return result
end

#Preprocess input dataset (rescale/reduce quantity of data/...):
#-------------------------------------------------------------------------------
#   (Updates display_data)
function preprocess_data(plot::Plot2D)
	#TODO: Find a way to preprocess x-vectors referencing same data only once?
	nstrips = length(plot.strips) #WANTCONST

	#Figure out required input data tranform for each strip:
	xflist = Vector{InputXfrm2D}(undef, nstrips)
	for i in 1:nstrips
		strip = plot.strips[i]

		#Need to take grid into account:
		xflist[i] = InputXfrm2D(plot.xscale, strip.yscale, strip.grid)
	end

	#Rescale data
	wfrmlist = map2axis(plot.data, xflist)

	for i in 1:nstrips
		strip = plot.strips[i]
		xf = InputXfrm2D(plot.xscale, strip.yscale)

		#Update extents:
		strip.ext_data = axis2read(getextents(wfrmlist, i), xf)
		_setyextents(strip, strip.yext) #Update extents, resolving any NaN fields.
	end

	#Extract maximum xextents from all strips:
	plot.xext_data = union([xvalues(strip.ext_data) for strip in plot.strips])
	_setxextents(plot, plot.xext) #Update extents, resolving any NaN fields.

	#Reduce data:
	xext = getxextents_axis(plot) #Read back extents, in transformed coordinates
	plot.display_data = _reduce(wfrmlist, xext, plot.pointdropmatrix, plot.xres)
	plot.invalid_ddata = false

	#NOTE: Rescaling before data reduction is somewhat inefficient, but makes
	#      it easier to interpolate data in _reduce step.
	#TODO: Find a way to efficiently reduce before re-scaling???
end

#==High-level display functions
===============================================================================#
function update_ddata(plot::Plot2D)
	invalidate_extents(plot) #Always refresh data
	#TODO: Conditionnaly compute (only when data changed/added)?

	refreshed = plot.invalid_ddata #Indicates if fn refreshed data
	if refreshed
		preprocess_data(plot)
	end
	return refreshed
end

#Last line


text:
module CoupledDipoles

using LinearAlgebra
using Distances
# using Plots, LaTeXStrings

using DifferentialEquations
using Logging: global_logger
using TerminalLoggers: TerminalLogger
global_logger(TerminalLogger())
# using ProgressMeter
# using Random
# using Statistics

using Printf
using LsqFit
using Optim: minimizer, optimize, Options
using SpecialFunctions: besseli
using Folds
using ThreadPools
using LazyArrays
using Memoize

const k₀ = 1
const Γ = 1
const probability_threshold = 0.9999
const R1_threshold = 0.5

include("structs.jl")
include("atom_cube.jl")
include("atom_sphere.jl")
include("formulas.jl")
include("IO.jl")
export Atom
export Square, Circle
export Cube, Sphere

export get_dimension
export Laser
export PlaneWave2D, PlaneWave3D
export Gaussian2D, Gaussian3D

export Physics, Linear
export LinearOptics, Scalar, Vectorial
export NonLinearOptics, MeanField, BBGKY

include("linear_problems.jl")
include("nonlinear_problems.jl")

include("atoms.jl")
export cube_inputs, sphere_inputs
export get_rₘᵢₙ
export get_pairwise_matrix

include("kernels.jl")
export get_interaction_matrix
export green_scalar!

# include("lasers.jl")
# export laser_over_atoms, estimate_waist
include("pump_gaussians.jl")
include("pump_planewaves.jl")
export apply_laser_over_atoms, apply_laser_over_oneAtom

include("eigen_analysis.jl")
export get_spectrum
export get_IPRs, get_PRs
export get_localization_length
# export get_spatial_profile_single_mode
export classify_modes

include("exponential_fit.jl")

# include("plot_modes.jl")
# export plot_atoms_and_mode
# export get_spatial_profile_data_to_save
# export get_atoms_matrix
# export get_X_axes, get_Y_axes, get_Z_axes

include("scattering.jl")
export get_intensities_over_sensors
# export get_geometric_factor

include("sensors.jl")
export get_sensors_ring

include("dynamics.jl")
export get_steady_state
export time_evolution, default_evolution_initial_condition, get_evolution_function

end


text:
module TestCHLaplacian

export interval_laplacian_ch, interval_laplacian_fd, interval_laplacian_chs

const tolerance = 1e-6 ## tolerance we compare to

include("../src/Chebyshev.jl")
include("../src/ChebyshevSpec.jl")
include("../src/CustomTypes.jl")
using .CustomTypes
import .Chebyshev     as CH
import .ChebyshevSpec as CHS

using LinearAlgebra: I, eigvals
using SparseArrays

import Test: @test

##============================================================
"""
Compare Eigenvalues on an interval using D2
"""
function interval_laplacian_ch(
      nx::myI,
      neig::myI,
      xmin::myF,
      xmax::myF
   )

   D1 = CH.mat_D1(xmin, xmax, nx)
   D2 = -D1*D1

   D2[1,1]      = 1.0
   D2[1,2:end] .= 0.0

   D2[nx,nx]      = 1.0
   D2[nx,1:nx-1] .= 0.0

   t = eigvals(D2,sortby=abs)

   L = xmax - xmin

   for (n,la) in enumerate(t[3:div(end,2,RoundNearest)])
      v = (pi*n/L)^2
      @test abs((la - v)/v) < tolerance
   end
end

"""
Compare Eigenvalues on an interval using finite difference D2
"""
function interval_laplacian_fd(
      nx::myI,
      neig::myI,
      xmin::myF,
      xmax::myF
   )

   D2 = -CH.mat_fd_D2(xmin,xmax,nx)

   D2[1,1]      = 1.0
   D2[1,2:end] .= 0.0

   D2[end,end]      = 1.0
   D2[nx,1:end-1] .= 0.0

   t = eigvals(D2,sortby=abs)

   L = xmax - xmin

   for (n,la) in enumerate(t[3:10])
      v = (pi*n/L)^2
      @test abs((la - v)/v) < 1e-3
   end
end

"""
Compare Eigenvalues on an interval using preconditioned spectral Chebyshev.
"""
function interval_laplacian_chs(
      nx::myI,
      neig::myI,
      xmin::myF,
      xmax::myF
   )
   L = xmax - xmin

   invD2 = CHS.mat_invD2(nx)
   id    = tomyF.(Float64.(sparse(I,nx,nx)))

   for i=1:nx
      id[1,i] = 1
      id[2,i] = (-1)^(i-1)
   end

   t = eigvals(Matrix(id),Matrix(invD2),sortby=abs)

   for (n,la) in enumerate(t[3:10])
      v = (pi*n/L)^2
      println("$v\t$la")
      @test abs((la - v)/v) < 1e-3
   end
end

end


text:
using LightGraphs
include("match.jl")

"""
basic_MIP
Returns a JuMP model with the basic matching MIP. On its own, solves the problem with
unbounded chains and cycles.
"""
function parse_input(filespec::String)
    f = open(filespec)
    l = readlines(f)
    close(f)
    problem_data, i = read_problem_data(l)
    root_nodes, i = read_nodes(l, i, "rootNodes")
    paired_nodes, i = read_nodes(l, i, "pairedNodes")
    terminal_nodes, i = read_nodes(l, i, "terminalNodes")
    edges, i = read_edges(l, i)
    return root_nodes, paired_nodes, terminal_nodes, edges, problem_data
end

function read_nodes(list, line, format)
    nodes = []
    nodes_name, nodes_number = split(list[line], ",")
	num_elems = parse(Int64, nodes_number)
    end_list = line + num_elems
	if num_elems != 0
		for k in (line + 1):(end_list)
			push!(nodes, list[k])
		end
	else
		while list[end_list+1] == ""
			end_list += 1
		end
	end
   	@assert lowercase(list[end_list + 1]) == lowercase("end" * format)

    return nodes, end_list + 2
end

function read_edges(list, line)
    edges = []
    edges_name, edges_number = split(list[line], ",")
    end_list = line + parse(Int64, edges_number)
    @assert lowercase(edges_name) == "edges"
    for k in (line + 1):(end_list)
        push!(edges, (split(list[k], ",")))
    end
    @assert lowercase(list[end_list + 1]) == "endedges"
    return edges, end_list + 2
end

function generate_graph(filespec::String)
    input = parse_input(filespec)
    root_nodes, paired_nodes, terminal_nodes, edges, problem_data = input
    number_nodes = length(root_nodes) + length(paired_nodes) + length(terminal_nodes)
    ndds = 1:length(root_nodes)

    graph = LightGraphs.SimpleDiGraph(number_nodes)
    id_map = Dict('r' => 0,
                  'p' => length(root_nodes),
                  't' => length(root_nodes) + length(paired_nodes))
    weights = zeros(Float64, (number_nodes, number_nodes))
    for e in edges
        edge_id, origin, dest, edge_weight = e
        o_id = find_index(origin, id_map)
        d_id = find_index(dest, id_map)

        add_edge!(graph, o_id, d_id)
        weights[o_id, d_id] = parse(Float64, edge_weight)
    end
    return graph, weights, ndds, problem_data
end

function find_index(node_name, map)
    letter = node_name[1]
    index = parse(Int64, node_name[2:end]) + map[letter]
    return index
end
"""
Parses problem data from a text comma-separated file
Returns the problem data as a dictionnary and the line number to keep reading the file
"""
function read_problem_data(list)
    problem_data = Dict()

    chain_length_str, chain_length = split(list[2], ",")
    @assert chain_length_str == "maxChainLength"
    if chain_length == "Infinity"
        chain_length = typemax(Int64)
    else
        chain_length = parse(Int64, chain_length)
    end
    problem_data["max_chain_length"] = chain_length

    cycle_length_str, cycle_length = split(list[3], ",")
    @assert cycle_length_str == "maxCycleLength"
    if cycle_length == "Infinity"
        cycle_length = typemax(Int64)
    else
        cycle_length = parse(Int64, cycle_length)
    end
    problem_data["max_cycle_length"] = cycle_length

    cycle_bonus = split(list[4], ",")
    @assert cycle_bonus[1] == "cycleBonus"
    problem_data["cycle_bonus"] = cycle_bonus[2]

    @assert list[5] == "endProblemData"

    return problem_data, 6
end

function write_to_csv(cycle_chains_list, filespec)
    mapping = Dict("chain"=> "endChain", "cycle"=> "endCycle")
    str = ""
    for cycle_chains in cycle_chains_list
        cat = cycle_chains[1]
        str *= cat * "\n"
        list_vert = cycle_chains[2]
        str_list_vert = join(list_vert, ", \n")
        str *= str_list_vert * "\n"
        str *= mapping[cat] * "\n"
    end
    open(filespec, "w") do f
        write(f, str)
    end
end


text:
# Memento allows one to remember history and restore an object's
# state to any prior state.
module MementoExample

# It can be easily achieved using immutable structs in Julia.
using Dates

# A single post
struct Post
    title::String
    content::String
end
Base.show(io::IO, p::Post) =
    print(io, "Post: ", p.title, " => ", p.content)

# Keep track of blog post versions in memory for undo purpose.
struct Blog
    author::String
    posts::Vector{Post}
    date_created::DateTime
end

# Constructor to create a new blog
function Blog(author::String, post::Post)
    return Blog(author, [post], now())
end

Base.show(io::IO, blog::Blog) =
    print(io, "Blog by ", blog.author,
        " created on ", blog.date_created)

# Update an existing blog post
function update!(blog::Blog;
                 title = nothing,
                 content = nothing)
    post = current_post(blog)
    new_post = Post(
        something(title, post.title),
        something(content, post.content)
    )
    push!(blog.posts, new_post)
    return new_post
end

# How many versions are availabe in this blog post?
version_count(blog::Blog) = length(blog.posts)

# Return the last version of the post
function undo!(blog::Blog)
    if version_count(blog) > 1
        pop!(blog.posts)
        return current_post(blog)
    else
        error("Cannot undo... no more previous history.")
    end
end

# latest version
current_post(blog::Blog) = blog.posts[end]

function test()
    blog = Blog("Tom", Post("Why is Julia so great?", "Blah blah."))
    update!(blog, content = "The reasons are...")

    println("Number of versions: ", version_count(blog))
    println("Current post")
    println(current_post(blog))

    println("Undo #1")
    undo!(blog)
    println(current_post(blog))

    println("Undo #2")  # expect failure
    undo!(blog)
    println(current_post(blog))
end

end #module

using .MementoExample
MementoExample.test()


text:
include("../coin-or-common.jl")

# Collection of sources required to build Clp
sources = [
    GitSource("https://github.com/coin-or/Clp.git", Clp_gitsha),
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/Clp*

# Remove misleading libtool files
rm -f ${prefix}/lib/*.la
update_configure_scripts

# old and custom autoconf
sed -i s/elf64ppc/elf64lppc/ configure

mkdir build
cd build/

export CPPFLAGS="${CPPFLAGS} -DNDEBUG -I${includedir} -I${includedir}/coin"
if [[ ${target} == *mingw* ]]; then
    export LDFLAGS="-L${libdir}"
elif [[ ${target} == *linux* ]]; then
    export LDFLAGS="-ldl -lrt"
fi

if [[ ${target} == *aarch64* ]] || [[ ${target} == *arm* ]]; then
   export CPPFLAGS="${CPPFLAGS} -D__arm__"
fi

../configure \
    --prefix=$prefix \
    --build=${MACHTYPE} \
    --host=${target} \
    --with-pic \
    --disable-pkg-config \
    --disable-debug \
    --disable-dependency-tracking \
    --enable-shared \
    lt_cv_deplibs_check_method=pass_all \
    --with-blas="-lopenblas" \
    --with-lapack="-lopenblas" \
    --with-coinutils-lib="-lCoinUtils" \
    --with-osi-lib="-lOsi -lCoinUtils" \
    --with-mumps-lib="-L${libdir} -ldmumps -lzmumps -lcmumps -lsmumps -lmumps_common -lmpiseq -lpord -lmetis -lopenblas -lgfortran -lpthread" \
    --with-mumps-incdir="${includedir}/mumps_seq" \
    --with-metis-lib="-L${libdir} -lmetis" \
    --with-metis-incdir="${includedir}"

make -j${nproc}
make install
"""

# The products that we will ensure are always built
products = [
    LibraryProduct("libClp", :libClp),
    LibraryProduct("libOsiClp", :libOsiClp),
    LibraryProduct("libClpSolver", :libClpSolver),
    ExecutableProduct("clp", :clp),
]

# Dependencies that must be installed before this package can be built
dependencies = [
    Dependency("CoinUtils_jll", CoinUtils_version),
    Dependency("Osi_jll", Osi_version),
    Dependency("METIS_jll", METIS_version),
    Dependency("MUMPS_seq_jll", MUMPS_seq_version),
    Dependency("OpenBLAS32_jll", OpenBLAS32_version),
    Dependency("CompilerSupportLibraries_jll"),
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(
    ARGS,
    "Clp",
    Clp_version,
    sources,
    script,
    expand_gfortran_versions(platforms),
    products,
    dependencies;
    preferred_gcc_version=gcc_version,
)

max_stars_repo_name: jameskermode/Yggdrasil

max_issues_repo_name: jameskermode/Yggdrasil

max_forks_repo_name: jameskermode/Yggdrasil