text:
export EVREye
const EVREye = CppEnum{Symbol("vr::EVREye"),UInt32}
export ETextureType
const ETextureType = CppEnum{Symbol("vr::ETextureType"),Int32}
export EColorSpace
const EColorSpace = CppEnum{Symbol("vr::EColorSpace"),UInt32}
export ETrackingResult
const ETrackingResult = CppEnum{Symbol("vr::ETrackingResult"),UInt32}
export ETrackedDeviceClass
const ETrackedDeviceClass = CppEnum{Symbol("vr::ETrackedDeviceClass"),UInt32}
export ETrackedControllerRole
const ETrackedControllerRole = CppEnum{Symbol("vr::ETrackedControllerRole"),UInt32}
export ETrackingUniverseOrigin
const ETrackingUniverseOrigin = CppEnum{Symbol("vr::ETrackingUniverseOrigin"),UInt32}
export ETrackedDeviceProperty
const ETrackedDeviceProperty = CppEnum{Symbol("vr::ETrackedDeviceProperty"),UInt32}
export ETrackedPropertyError
const ETrackedPropertyError = CppEnum{Symbol("vr::ETrackedPropertyError"),UInt32}
export EVRSubmitFlags
const EVRSubmitFlags = CppEnum{Symbol("vr::EVRSubmitFlags"),UInt32}
export EVRState
const EVRState = CppEnum{Symbol("vr::EVRState"),Int32}
export EVREventType
const EVREventType = CppEnum{Symbol("vr::EVREventType"),UInt32}
export EDeviceActivityLevel
const EDeviceActivityLevel = CppEnum{Symbol("vr::EDeviceActivityLevel"),Int32}
export EVRButtonId
const EVRButtonId = CppEnum{Symbol("vr::EVRButtonId"),UInt32}
export EVRMouseButton
const EVRMouseButton = CppEnum{Symbol("vr::EVRMouseButton"),UInt32}
export EDualAnalogWhich
const EDualAnalogWhich = CppEnum{Symbol("vr::EDualAnalogWhich"),UInt32}
export EShowUIType
const EShowUIType = CppEnum{Symbol("vr::EShowUIType"),UInt32}
export EVRInputError
const EVRInputError = CppEnum{Symbol("vr::EVRInputError"),UInt32}
export EVRSpatialAnchorError
const EVRSpatialAnchorError = CppEnum{Symbol("vr::EVRSpatialAnchorError"),UInt32}
export EHiddenAreaMeshType
const EHiddenAreaMeshType = CppEnum{Symbol("vr::EHiddenAreaMeshType"),UInt32}
export EVRControllerAxisType
const EVRControllerAxisType = CppEnum{Symbol("vr::EVRControllerAxisType"),UInt32}
export EVRControllerEventOutputType
const EVRControllerEventOutputType = CppEnum{Symbol("vr::EVRControllerEventOutputType"),UInt32}
export ECollisionBoundsStyle
const ECollisionBoundsStyle = CppEnum{Symbol("vr::ECollisionBoundsStyle"),UInt32}
export EVROverlayError
const EVROverlayError = CppEnum{Symbol("vr::EVROverlayError"),UInt32}
export EVRApplicationType
const EVRApplicationType = CppEnum{Symbol("vr::EVRApplicationType"),UInt32}
export EVRFirmwareError
const EVRFirmwareError = CppEnum{Symbol("vr::EVRFirmwareError"),UInt32}
export EVRNotificationError
const EVRNotificationError = CppEnum{Symbol("vr::EVRNotificationError"),UInt32}
export EVRSkeletalMotionRange
const EVRSkeletalMotionRange = CppEnum{Symbol("vr::EVRSkeletalMotionRange"),UInt32}
export EVRSkeletalTrackingLevel
const EVRSkeletalTrackingLevel = CppEnum{Symbol("vr::EVRSkeletalTrackingLevel"),UInt32}
export EVRInitError
const EVRInitError = CppEnum{Symbol("vr::EVRInitError"),UInt32}
export EVRScreenshotType
const EVRScreenshotType = CppEnum{Symbol("vr::EVRScreenshotType"),UInt32}
export EVRScreenshotPropertyFilenames
const EVRScreenshotPropertyFilenames = CppEnum{Symbol("vr::EVRScreenshotPropertyFilenames"),UInt32}
export EVRTrackedCameraError
const EVRTrackedCameraError = CppEnum{Symbol("vr::EVRTrackedCameraError"),UInt32}
export EVRTrackedCameraFrameLayout
const EVRTrackedCameraFrameLayout = CppEnum{Symbol("vr::EVRTrackedCameraFrameLayout"),UInt32}
export EVRTrackedCameraFrameType
const EVRTrackedCameraFrameType = CppEnum{Symbol("vr::EVRTrackedCameraFrameType"),UInt32}
export EVRDistortionFunctionType
const EVRDistortionFunctionType = CppEnum{Symbol("vr::EVRDistortionFunctionType"),UInt32}
export EVSync
const EVSync = CppEnum{Symbol("vr::EVSync"),UInt32}
export EVRMuraCorrectionMode
const EVRMuraCorrectionMode = CppEnum{Symbol("vr::EVRMuraCorrectionMode"),UInt32}
export Imu_OffScaleFlags
const Imu_OffScaleFlags = CppEnum{Symbol("vr::Imu_OffScaleFlags"),UInt32}
export EVRApplicationError
const EVRApplicationError = CppEnum{Symbol("vr::EVRApplicationError"),UInt32}
export EVRApplicationProperty
const EVRApplicationProperty = CppEnum{Symbol("vr::EVRApplicationProperty"),UInt32}
export EVRSettingsError
const EVRSettingsError = CppEnum{Symbol("vr::EVRSettingsError"),UInt32}
export ChaperoneCalibrationState
const ChaperoneCalibrationState = CppEnum{Symbol("vr::ChaperoneCalibrationState"),UInt32}
export EChaperoneConfigFile
const EChaperoneConfigFile = CppEnum{Symbol("vr::EChaperoneConfigFile"),UInt32}
export EChaperoneImportFlags
const EChaperoneImportFlags = CppEnum{Symbol("vr::EChaperoneImportFlags"),UInt32}
export EVRCompositorError
const EVRCompositorError = CppEnum{Symbol("vr::EVRCompositorError"),UInt32}
export EVRCompositorTimingMode
const EVRCompositorTimingMode = CppEnum{Symbol("vr::EVRCompositorTimingMode"),UInt32}
export EVRNotificationType
const EVRNotificationType = CppEnum{Symbol("vr::EVRNotificationType"),UInt32}
export EVRNotificationStyle
const EVRNotificationStyle = CppEnum{Symbol("vr::EVRNotificationStyle"),UInt32}
export VROverlayInputMethod
const VROverlayInputMethod = CppEnum{Symbol("vr::VROverlayInputMethod"),UInt32}
export VROverlayTransformType
const VROverlayTransformType = CppEnum{Symbol("vr::VROverlayTransformType"),Int32}
export VROverlayFlags
const VROverlayFlags = CppEnum{Symbol("vr::VROverlayFlags"),UInt32}
export VRMessageOverlayResponse
const VRMessageOverlayResponse = CppEnum{Symbol("vr::VRMessageOverlayResponse"),UInt32}
export EGamepadTextInputMode
const EGamepadTextInputMode = CppEnum{Symbol("vr::EGamepadTextInputMode"),UInt32}
export EGamepadTextInputLineMode
const EGamepadTextInputLineMode = CppEnum{Symbol("vr::EGamepadTextInputLineMode"),UInt32}
export EVROverlayIntersectionMaskPrimitiveType
const EVROverlayIntersectionMaskPrimitiveType = CppEnum{Symbol("vr::EVROverlayIntersectionMaskPrimitiveType"),UInt32}
export EVRRenderModelError
const EVRRenderModelError = CppEnum{Symbol("vr::EVRRenderModelError"),UInt32}
export EVRComponentProperty
const EVRComponentProperty = CppEnum{Symbol("vr::EVRComponentProperty"),UInt32}
export EVRScreenshotError
const EVRScreenshotError = CppEnum{Symbol("vr::EVRScreenshotError"),UInt32}
export EVRSkeletalTransformSpace
const EVRSkeletalTransformSpace = CppEnum{Symbol("vr::EVRSkeletalTransformSpace"),UInt32}
export EVRSkeletalReferencePose
const EVRSkeletalReferencePose = CppEnum{Symbol("vr::EVRSkeletalReferencePose"),UInt32}
export EVRFinger
const EVRFinger = CppEnum{Symbol("vr::EVRFinger"),UInt32}
export EVRFingerSplay
const EVRFingerSplay = CppEnum{Symbol("vr::EVRFingerSplay"),UInt32}
export EVRInputFilterCancelType
const EVRInputFilterCancelType = CppEnum{Symbol("vr::EVRInputFilterCancelType"),UInt32}
export EVRInputStringBits
const EVRInputStringBits = CppEnum{Symbol("vr::EVRInputStringBits"),UInt32}
export EIOBufferError
const EIOBufferError = CppEnum{Symbol("vr::EIOBufferError"),UInt32}
export EIOBufferMode
const EIOBufferMode = CppEnum{Symbol("vr::EIOBufferMode"),UInt32}
const Eye_Left = EVREye(0)
const Eye_Right = EVREye(1)
const TextureType_Invalid = ETextureType(-1)
const TextureType_DirectX = ETextureType(0)
const TextureType_OpenGL = ETextureType(1)
const TextureType_Vulkan = ETextureType(2)
const TextureType_IOSurface = ETextureType(3)
const TextureType_DirectX12 = ETextureType(4)
const TextureType_DXGISharedHandle = ETextureType(5)
const TextureType_Metal = ETextureType(6)
const ColorSpace_Auto = EColorSpace(0)
const ColorSpace_Gamma = EColorSpace(1)
const ColorSpace_Linear = EColorSpace(2)
const TrackingResult_Uninitialized = ETrackingResult(1)
const TrackingResult_Calibrating_InProgress = ETrackingResult(100)
const TrackingResult_Calibrating_OutOfRange = ETrackingResult(101)
const TrackingResult_Running_OK = ETrackingResult(200)
const TrackingResult_Running_OutOfRange = ETrackingResult(201)
const TrackingResult_Fallback_RotationOnly = ETrackingResult(300)
const TrackedDeviceClass_Invalid = ETrackedDeviceClass(0)
const TrackedDeviceClass_HMD = ETrackedDeviceClass(1)
const TrackedDeviceClass_Controller = ETrackedDeviceClass(2)
const TrackedDeviceClass_GenericTracker = ETrackedDeviceClass(3)
const TrackedDeviceClass_TrackingReference = ETrackedDeviceClass(4)
const TrackedDeviceClass_DisplayRedirect = ETrackedDeviceClass(5)
const TrackedDeviceClass_Max = ETrackedDeviceClass(6)
const TrackedControllerRole_Invalid = ETrackedControllerRole(0)
const TrackedControllerRole_LeftHand = ETrackedControllerRole(1)
const TrackedControllerRole_RightHand = ETrackedControllerRole(2)
const TrackedControllerRole_OptOut = ETrackedControllerRole(3)
const TrackedControllerRole_Treadmill = ETrackedControllerRole(4)
const TrackedControllerRole_Max = ETrackedControllerRole(5)
const TrackingUniverseSeated = ETrackingUniverseOrigin(0)
const TrackingUniverseStanding = ETrackingUniverseOrigin(1)
const TrackingUniverseRawAndUncalibrated = ETrackingUniverseOrigin(2)
const Prop_Invalid = ETrackedDeviceProperty(0)
const Prop_TrackingSystemName_String = ETrackedDeviceProperty(1000)
const Prop_ModelNumber_String = ETrackedDeviceProperty(1001)
const Prop_SerialNumber_String = ETrackedDeviceProperty(1002)
const Prop_RenderModelName_String = ETrackedDeviceProperty(1003)
const Prop_WillDriftInYaw_Bool = ETrackedDeviceProperty(1004)
const Prop_ManufacturerName_String = ETrackedDeviceProperty(1005)
const Prop_TrackingFirmwareVersion_String = ETrackedDeviceProperty(1006)
const Prop_HardwareRevision_String = ETrackedDeviceProperty(1007)
const Prop_AllWirelessDongleDescriptions_String = ETrackedDeviceProperty(1008)
const Prop_ConnectedWirelessDongle_String = ETrackedDeviceProperty(1009)
const Prop_DeviceIsWireless_Bool = ETrackedDeviceProperty(1010)
const Prop_DeviceIsCharging_Bool = ETrackedDeviceProperty(1011)
const Prop_DeviceBatteryPercentage_Float = ETrackedDeviceProperty(1012)
const Prop_StatusDisplayTransform_Matrix34 = ETrackedDeviceProperty(1013)
const Prop_Firmware_UpdateAvailable_Bool = ETrackedDeviceProperty(1014)
const Prop_Firmware_ManualUpdate_Bool = ETrackedDeviceProperty(1015)
const Prop_Firmware_ManualUpdateURL_String = ETrackedDeviceProperty(1016)
const Prop_HardwareRevision_Uint64 = ETrackedDeviceProperty(1017)
const Prop_FirmwareVersion_Uint64 = ETrackedDeviceProperty(1018)
const Prop_FPGAVersion_Uint64 = ETrackedDeviceProperty(1019)
const Prop_VRCVersion_Uint64 = ETrackedDeviceProperty(1020)
const Prop_RadioVersion_Uint64 = ETrackedDeviceProperty(1021)
const Prop_DongleVersion_Uint64 = ETrackedDeviceProperty(1022)
const Prop_BlockServerShutdown_Bool = ETrackedDeviceProperty(1023)
const Prop_CanUnifyCoordinateSystemWithHmd_Bool = ETrackedDeviceProperty(1024)
const Prop_ContainsProximitySensor_Bool = ETrackedDeviceProperty(1025)
const Prop_DeviceProvidesBatteryStatus_Bool = ETrackedDeviceProperty(1026)
const Prop_DeviceCanPowerOff_Bool = ETrackedDeviceProperty(1027)
const Prop_Firmware_ProgrammingTarget_String = ETrackedDeviceProperty(1028)
const Prop_DeviceClass_Int32 = ETrackedDeviceProperty(1029)
const Prop_HasCamera_Bool = ETrackedDeviceProperty(1030)
const Prop_DriverVersion_String = ETrackedDeviceProperty(1031)
const Prop_Firmware_ForceUpdateRequired_Bool = ETrackedDeviceProperty(1032)
const Prop_ViveSystemButtonFixRequired_Bool = ETrackedDeviceProperty(1033)
const Prop_ParentDriver_Uint64 = ETrackedDeviceProperty(1034)
const Prop_ResourceRoot_String = ETrackedDeviceProperty(1035)
const Prop_RegisteredDeviceType_String = ETrackedDeviceProperty(1036)
const Prop_InputProfilePath_String = ETrackedDeviceProperty(1037)
const Prop_NeverTracked_Bool = ETrackedDeviceProperty(1038)
const Prop_NumCameras_Int32 = ETrackedDeviceProperty(1039)
const Prop_CameraFrameLayout_Int32 = ETrackedDeviceProperty(1040)
const Prop_CameraStreamFormat_Int32 = ETrackedDeviceProperty(1041)
const Prop_AdditionalDeviceSettingsPath_String = ETrackedDeviceProperty(1042)
const Prop_Identifiable_Bool = ETrackedDeviceProperty(1043)
const Prop_ReportsTimeSinceVSync_Bool = ETrackedDeviceProperty(2000)
const Prop_SecondsFromVsyncToPhotons_Float = ETrackedDeviceProperty(2001)
const Prop_DisplayFrequency_Float = ETrackedDeviceProperty(2002)
const Prop_UserIpdMeters_Float = ETrackedDeviceProperty(2003)
const Prop_CurrentUniverseId_Uint64 = ETrackedDeviceProperty(2004)
const Prop_PreviousUniverseId_Uint64 = ETrackedDeviceProperty(2005)
const Prop_DisplayFirmwareVersion_Uint64 = ETrackedDeviceProperty(2006)
const Prop_IsOnDesktop_Bool = ETrackedDeviceProperty(2007)
const Prop_DisplayMCType_Int32 = ETrackedDeviceProperty(2008)
const Prop_DisplayMCOffset_Float = ETrackedDeviceProperty(2009)
const Prop_DisplayMCScale_Float = ETrackedDeviceProperty(2010)
const Prop_EdidVendorID_Int32 = ETrackedDeviceProperty(2011)
const Prop_DisplayMCImageLeft_String = ETrackedDeviceProperty(2012)
const Prop_DisplayMCImageRight_String = ETrackedDeviceProperty(2013)
const Prop_DisplayGCBlackClamp_Float = ETrackedDeviceProperty(2014)
const Prop_EdidProductID_Int32 = ETrackedDeviceProperty(2015)
const Prop_CameraToHeadTransform_Matrix34 = ETrackedDeviceProperty(2016)
const Prop_DisplayGCType_Int32 = ETrackedDeviceProperty(2017)
const Prop_DisplayGCOffset_Float = ETrackedDeviceProperty(2018)
const Prop_DisplayGCScale_Float = ETrackedDeviceProperty(2019)
const Prop_DisplayGCPrescale_Float = ETrackedDeviceProperty(2020)
const Prop_DisplayGCImage_String = ETrackedDeviceProperty(2021)
const Prop_LensCenterLeftU_Float = ETrackedDeviceProperty(2022)
const Prop_LensCenterLeftV_Float = ETrackedDeviceProperty(2023)
const Prop_LensCenterRightU_Float = ETrackedDeviceProperty(2024)
const Prop_LensCenterRightV_Float = ETrackedDeviceProperty(2025)
const Prop_UserHeadToEyeDepthMeters_Float = ETrackedDeviceProperty(2026)
const Prop_CameraFirmwareVersion_Uint64 = ETrackedDeviceProperty(2027)
const Prop_CameraFirmwareDescription_String = ETrackedDeviceProperty(2028)
const Prop_DisplayFPGAVersion_Uint64 = ETrackedDeviceProperty(2029)
const Prop_DisplayBootloaderVersion_Uint64 = ETrackedDeviceProperty(2030)
const Prop_DisplayHardwareVersion_Uint64 = ETrackedDeviceProperty(2031)
const Prop_AudioFirmwareVersion_Uint64 = ETrackedDeviceProperty(2032)
const Prop_CameraCompatibilityMode_Int32 = ETrackedDeviceProperty(2033)
const Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = ETrackedDeviceProperty(2034)
const Prop_ScreenshotVerticalFieldOfViewDegrees_Float = ETrackedDeviceProperty(2035)
const Prop_DisplaySuppressed_Bool = ETrackedDeviceProperty(2036)
const Prop_DisplayAllowNightMode_Bool = ETrackedDeviceProperty(2037)
const Prop_DisplayMCImageWidth_Int32 = ETrackedDeviceProperty(2038)
const Prop_DisplayMCImageHeight_Int32 = ETrackedDeviceProperty(2039)
const Prop_DisplayMCImageNumChannels_Int32 = ETrackedDeviceProperty(2040)
const Prop_DisplayMCImageData_Binary = ETrackedDeviceProperty(2041)
const Prop_SecondsFromPhotonsToVblank_Float = ETrackedDeviceProperty(2042)
const Prop_DriverDirectModeSendsVsyncEvents_Bool = ETrackedDeviceProperty(2043)
const Prop_DisplayDebugMode_Bool = ETrackedDeviceProperty(2044)
const Prop_GraphicsAdapterLuid_Uint64 = ETrackedDeviceProperty(2045)
const Prop_DriverProvidedChaperonePath_String = ETrackedDeviceProperty(2048)
const Prop_ExpectedTrackingReferenceCount_Int32 = ETrackedDeviceProperty(2049)
const Prop_ExpectedControllerCount_Int32 = ETrackedDeviceProperty(2050)
const Prop_NamedIconPathControllerLeftDeviceOff_String = ETrackedDeviceProperty(2051)
const Prop_NamedIconPathControllerRightDeviceOff_String = ETrackedDeviceProperty(2052)
const Prop_NamedIconPathTrackingReferenceDeviceOff_String = ETrackedDeviceProperty(2053)
const Prop_DoNotApplyPrediction_Bool = ETrackedDeviceProperty(2054)
const Prop_CameraToHeadTransforms_Matrix34_Array = ETrackedDeviceProperty(2055)
const Prop_DistortionMeshResolution_Int32 = ETrackedDeviceProperty(2056)
const Prop_DriverIsDrawingControllers_Bool = ETrackedDeviceProperty(2057)
const Prop_DriverRequestsApplicationPause_Bool = ETrackedDeviceProperty(2058)
const Prop_DriverRequestsReducedRendering_Bool = ETrackedDeviceProperty(2059)
const Prop_MinimumIpdStepMeters_Float = ETrackedDeviceProperty(2060)
const Prop_AudioBridgeFirmwareVersion_Uint64 = ETrackedDeviceProperty(2061)
const Prop_ImageBridgeFirmwareVersion_Uint64 = ETrackedDeviceProperty(2062)
const Prop_ImuToHeadTransform_Matrix34 = ETrackedDeviceProperty(2063)
const Prop_ImuFactoryGyroBias_Vector3 = ETrackedDeviceProperty(2064)
const Prop_ImuFactoryGyroScale_Vector3 = ETrackedDeviceProperty(2065)
const Prop_ImuFactoryAccelerometerBias_Vector3 = ETrackedDeviceProperty(2066)
const Prop_ImuFactoryAccelerometerScale_Vector3 = ETrackedDeviceProperty(2067)
const Prop_ConfigurationIncludesLighthouse20Features_Bool = ETrackedDeviceProperty(2069)
const Prop_DriverRequestedMuraCorrectionMode_Int32 = ETrackedDeviceProperty(2200)
const Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = ETrackedDeviceProperty(2201)
const Prop_DriverRequestedMuraFeather_InnerRight_Int32 = ETrackedDeviceProperty(2202)
const Prop_DriverRequestedMuraFeather_InnerTop_Int32 = ETrackedDeviceProperty(2203)
const Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = ETrackedDeviceProperty(2204)
const Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = ETrackedDeviceProperty(2205)
const Prop_DriverRequestedMuraFeather_OuterRight_Int32 = ETrackedDeviceProperty(2206)
const Prop_DriverRequestedMuraFeather_OuterTop_Int32 = ETrackedDeviceProperty(2207)
const Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = ETrackedDeviceProperty(2208)
const Prop_AttachedDeviceId_String = ETrackedDeviceProperty(3000)
const Prop_SupportedButtons_Uint64 = ETrackedDeviceProperty(3001)
const Prop_Axis0Type_Int32 = ETrackedDeviceProperty(3002)
const Prop_Axis1Type_Int32 = ETrackedDeviceProperty(3003)
const Prop_Axis2Type_Int32 = ETrackedDeviceProperty(3004)
const Prop_Axis3Type_Int32 = ETrackedDeviceProperty(3005)
const Prop_Axis4Type_Int32 = ETrackedDeviceProperty(3006)
const Prop_ControllerRoleHint_Int32 = ETrackedDeviceProperty(3007)
const Prop_FieldOfViewLeftDegrees_Float = ETrackedDeviceProperty(4000)
const Prop_FieldOfViewRightDegrees_Float = ETrackedDeviceProperty(4001)
const Prop_FieldOfViewTopDegrees_Float = ETrackedDeviceProperty(4002)
const Prop_FieldOfViewBottomDegrees_Float = ETrackedDeviceProperty(4003)
const Prop_TrackingRangeMinimumMeters_Float = ETrackedDeviceProperty(4004)
const Prop_TrackingRangeMaximumMeters_Float = ETrackedDeviceProperty(4005)
const Prop_ModeLabel_String = ETrackedDeviceProperty(4006)
const Prop_IconPathName_String = ETrackedDeviceProperty(5000)
const Prop_NamedIconPathDeviceOff_String = ETrackedDeviceProperty(5001)
const Prop_NamedIconPathDeviceSearching_String = ETrackedDeviceProperty(5002)
const Prop_NamedIconPathDeviceSearchingAlert_String = ETrackedDeviceProperty(5003)
const Prop_NamedIconPathDeviceReady_String = ETrackedDeviceProperty(5004)
const Prop_NamedIconPathDeviceReadyAlert_String = ETrackedDeviceProperty(5005)
const Prop_NamedIconPathDeviceNotReady_String = ETrackedDeviceProperty(5006)
const Prop_NamedIconPathDeviceStandby_String = ETrackedDeviceProperty(5007)
const Prop_NamedIconPathDeviceAlertLow_String = ETrackedDeviceProperty(5008)
const Prop_DisplayHiddenArea_Binary_Start = ETrackedDeviceProperty(5100)
const Prop_DisplayHiddenArea_Binary_End = ETrackedDeviceProperty(5150)
const Prop_ParentContainer = ETrackedDeviceProperty(5151)
const Prop_UserConfigPath_String = ETrackedDeviceProperty(6000)
const Prop_InstallPath_String = ETrackedDeviceProperty(6001)
const Prop_HasDisplayComponent_Bool = ETrackedDeviceProperty(6002)
const Prop_HasControllerComponent_Bool = ETrackedDeviceProperty(6003)
const Prop_HasCameraComponent_Bool = ETrackedDeviceProperty(6004)
const Prop_HasDriverDirectModeComponent_Bool = ETrackedDeviceProperty(6005)
const Prop_HasVirtualDisplayComponent_Bool = ETrackedDeviceProperty(6006)
const Prop_HasSpatialAnchorsSupport_Bool = ETrackedDeviceProperty(6007)
const Prop_ControllerType_String = ETrackedDeviceProperty(7000)
const Prop_ControllerHandSelectionPriority_Int32 = ETrackedDeviceProperty(7002)
const Prop_VendorSpecific_Reserved_Start = ETrackedDeviceProperty(10000)
const Prop_VendorSpecific_Reserved_End = ETrackedDeviceProperty(10999)
const Prop_TrackedDeviceProperty_Max = ETrackedDeviceProperty(1000000)
const TrackedProp_Success = ETrackedPropertyError(0)
const TrackedProp_WrongDataType = ETrackedPropertyError(1)
const TrackedProp_WrongDeviceClass = ETrackedPropertyError(2)
const TrackedProp_BufferTooSmall = ETrackedPropertyError(3)
const TrackedProp_UnknownProperty = ETrackedPropertyError(4)
const TrackedProp_InvalidDevice = ETrackedPropertyError(5)
const TrackedProp_CouldNotContactServer = ETrackedPropertyError(6)
const TrackedProp_ValueNotProvidedByDevice = ETrackedPropertyError(7)
const TrackedProp_StringExceedsMaximumLength = ETrackedPropertyError(8)
const TrackedProp_NotYetAvailable = ETrackedPropertyError(9)
const TrackedProp_PermissionDenied = ETrackedPropertyError(10)
const TrackedProp_InvalidOperation = ETrackedPropertyError(11)
const TrackedProp_CannotWriteToWildcards = ETrackedPropertyError(12)
const TrackedProp_IPCReadFailure = ETrackedPropertyError(13)
const Submit_Default = EVRSubmitFlags(0)
const Submit_LensDistortionAlreadyApplied = EVRSubmitFlags(1)
const Submit_GlRenderBuffer = EVRSubmitFlags(2)
const Submit_Reserved = EVRSubmitFlags(4)
const Submit_TextureWithPose = EVRSubmitFlags(8)
const Submit_TextureWithDepth = EVRSubmitFlags(16)
const VRState_Undefined = EVRState(-1)
const VRState_Off = EVRState(0)
const VRState_Searching = EVRState(1)
const VRState_Searching_Alert = EVRState(2)
const VRState_Ready = EVRState(3)
const VRState_Ready_Alert = EVRState(4)
const VRState_NotReady = EVRState(5)
const VRState_Standby = EVRState(6)
const VRState_Ready_Alert_Low = EVRState(7)
const VREvent_None = EVREventType(0)
const VREvent_TrackedDeviceActivated = EVREventType(100)
const VREvent_TrackedDeviceDeactivated = EVREventType(101)
const VREvent_TrackedDeviceUpdated = EVREventType(102)
const VREvent_TrackedDeviceUserInteractionStarted = EVREventType(103)
const VREvent_TrackedDeviceUserInteractionEnded = EVREventType(104)
const VREvent_IpdChanged = EVREventType(105)
const VREvent_EnterStandbyMode = EVREventType(106)
const VREvent_LeaveStandbyMode = EVREventType(107)
const VREvent_TrackedDeviceRoleChanged = EVREventType(108)
const VREvent_WatchdogWakeUpRequested = EVREventType(109)
const VREvent_LensDistortionChanged = EVREventType(110)
const VREvent_PropertyChanged = EVREventType(111)
const VREvent_WirelessDisconnect = EVREventType(112)
const VREvent_WirelessReconnect = EVREventType(113)
const VREvent_ButtonPress = EVREventType(200)
const VREvent_ButtonUnpress = EVREventType(201)
const VREvent_ButtonTouch = EVREventType(202)
const VREvent_ButtonUntouch = EVREventType(203)
const VREvent_DualAnalog_Press = EVREventType(250)
const VREvent_DualAnalog_Unpress = EVREventType(251)
const VREvent_DualAnalog_Touch = EVREventType(252)
const VREvent_DualAnalog_Untouch = EVREventType(253)
const VREvent_DualAnalog_Move = EVREventType(254)
const VREvent_DualAnalog_ModeSwitch1 = EVREventType(255)
const VREvent_DualAnalog_ModeSwitch2 = EVREventType(256)
const VREvent_DualAnalog_Cancel = EVREventType(257)
const VREvent_MouseMove = EVREventType(300)
const VREvent_MouseButtonDown = EVREventType(301)
const VREvent_MouseButtonUp = EVREventType(302)
const VREvent_FocusEnter = EVREventType(303)
const VREvent_FocusLeave = EVREventType(304)
const VREvent_TouchPadMove = EVREventType(306)
const VREvent_OverlayFocusChanged = EVREventType(307)
const VREvent_ReloadOverlays = EVREventType(308)
const VREvent_InputFocusCaptured = EVREventType(400)
const VREvent_InputFocusReleased = EVREventType(401)
const VREvent_SceneFocusChanged = EVREventType(405)
const VREvent_InputFocusChanged = EVREventType(406)
const VREvent_SceneApplicationUsingWrongGraphicsAdapter = EVREventType(408)
const VREvent_ActionBindingReloaded = EVREventType(409)
const VREvent_HideRenderModels = EVREventType(410)
const VREvent_ShowRenderModels = EVREventType(411)
const VREvent_ConsoleOpened = EVREventType(420)
const VREvent_ConsoleClosed = EVREventType(421)
const VREvent_OverlayShown = EVREventType(500)
const VREvent_OverlayHidden = EVREventType(501)
const VREvent_DashboardActivated = EVREventType(502)
const VREvent_DashboardDeactivated = EVREventType(503)
const VREvent_DashboardRequested = EVREventType(505)
const VREvent_ResetDashboard = EVREventType(506)
const VREvent_RenderToast = EVREventType(507)
const VREvent_ImageLoaded = EVREventType(508)
const VREvent_ShowKeyboard = EVREventType(509)
const VREvent_HideKeyboard = EVREventType(510)
const VREvent_OverlayGamepadFocusGained = EVREventType(511)
const VREvent_OverlayGamepadFocusLost = EVREventType(512)
const VREvent_OverlaySharedTextureChanged = EVREventType(513)
const VREvent_ScreenshotTriggered = EVREventType(516)
const VREvent_ImageFailed = EVREventType(517)
const VREvent_DashboardOverlayCreated = EVREventType(518)
const VREvent_SwitchGamepadFocus = EVREventType(519)
const VREvent_RequestScreenshot = EVREventType(520)
const VREvent_ScreenshotTaken = EVREventType(521)
const VREvent_ScreenshotFailed = EVREventType(522)
const VREvent_SubmitScreenshotToDashboard = EVREventType(523)
const VREvent_ScreenshotProgressToDashboard = EVREventType(524)
const VREvent_PrimaryDashboardDeviceChanged = EVREventType(525)
const VREvent_RoomViewShown = EVREventType(526)
const VREvent_RoomViewHidden = EVREventType(527)
const VREvent_ShowUI = EVREventType(528)
const VREvent_Notification_Shown = EVREventType(600)
const VREvent_Notification_Hidden = EVREventType(601)
const VREvent_Notification_BeginInteraction = EVREventType(602)
const VREvent_Notification_Destroyed = EVREventType(603)
const VREvent_Quit = EVREventType(700)
const VREvent_ProcessQuit = EVREventType(701)
const VREvent_QuitAcknowledged = EVREventType(703)
const VREvent_DriverRequestedQuit = EVREventType(704)
const VREvent_ChaperoneDataHasChanged = EVREventType(800)
const VREvent_ChaperoneUniverseHasChanged = EVREventType(801)
const VREvent_ChaperoneTempDataHasChanged = EVREventType(802)
const VREvent_ChaperoneSettingsHaveChanged = EVREventType(803)
const VREvent_SeatedZeroPoseReset = EVREventType(804)
const VREvent_ChaperoneFlushCache = EVREventType(805)
const VREvent_AudioSettingsHaveChanged = EVREventType(820)
const VREvent_BackgroundSettingHasChanged = EVREventType(850)
const VREvent_CameraSettingsHaveChanged = EVREventType(851)
const VREvent_ReprojectionSettingHasChanged = EVREventType(852)
const VREvent_ModelSkinSettingsHaveChanged = EVREventType(853)
const VREvent_EnvironmentSettingsHaveChanged = EVREventType(854)
const VREvent_PowerSettingsHaveChanged = EVREventType(855)
const VREvent_EnableHomeAppSettingsHaveChanged = EVREventType(856)
const VREvent_SteamVRSectionSettingChanged = EVREventType(857)
const VREvent_LighthouseSectionSettingChanged = EVREventType(858)
const VREvent_NullSectionSettingChanged = EVREventType(859)
const VREvent_UserInterfaceSectionSettingChanged = EVREventType(860)
const VREvent_NotificationsSectionSettingChanged = EVREventType(861)
const VREvent_KeyboardSectionSettingChanged = EVREventType(862)
const VREvent_PerfSectionSettingChanged = EVREventType(863)
const VREvent_DashboardSectionSettingChanged = EVREventType(864)
const VREvent_WebInterfaceSectionSettingChanged = EVREventType(865)
const VREvent_TrackersSectionSettingChanged = EVREventType(866)
const VREvent_LastKnownSectionSettingChanged = EVREventType(867)
const VREvent_StatusUpdate = EVREventType(900)
const VREvent_WebInterface_InstallDriverCompleted = EVREventType(950)
const VREvent_MCImageUpdated = EVREventType(1000)
const VREvent_FirmwareUpdateStarted = EVREventType(1100)
const VREvent_FirmwareUpdateFinished = EVREventType(1101)
const VREvent_KeyboardClosed = EVREventType(1200)
const VREvent_KeyboardCharInput = EVREventType(1201)
const VREvent_KeyboardDone = EVREventType(1202)
const VREvent_ApplicationListUpdated = EVREventType(1303)
const VREvent_ApplicationMimeTypeLoad = EVREventType(1304)
const VREvent_ProcessConnected = EVREventType(1306)
const VREvent_ProcessDisconnected = EVREventType(1307)
const VREvent_Compositor_ChaperoneBoundsShown = EVREventType(1410)
const VREvent_Compositor_ChaperoneBoundsHidden = EVREventType(1411)
const VREvent_TrackedCamera_StartVideoStream = EVREventType(1500)
const VREvent_TrackedCamera_StopVideoStream = EVREventType(1501)
const VREvent_TrackedCamera_PauseVideoStream = EVREventType(1502)
const VREvent_TrackedCamera_ResumeVideoStream = EVREventType(1503)
const VREvent_TrackedCamera_EditingSurface = EVREventType(1550)
const VREvent_PerformanceTest_EnableCapture = EVREventType(1600)
const VREvent_PerformanceTest_DisableCapture = EVREventType(1601)
const VREvent_PerformanceTest_FidelityLevel = EVREventType(1602)
const VREvent_MessageOverlay_Closed = EVREventType(1650)
const VREvent_MessageOverlayCloseRequested = EVREventType(1651)
const VREvent_Input_HapticVibration = EVREventType(1700)
const VREvent_Input_BindingLoadFailed = EVREventType(1701)
const VREvent_Input_BindingLoadSuccessful = EVREventType(1702)
const VREvent_Input_ActionManifestReloaded = EVREventType(1703)
const VREvent_Input_ActionManifestLoadFailed = EVREventType(1704)
const VREvent_Input_ProgressUpdate = EVREventType(1705)
const VREvent_Input_TrackerActivated = EVREventType(1706)
const VREvent_SpatialAnchors_PoseUpdated = EVREventType(1800)
const VREvent_SpatialAnchors_DescriptorUpdated = EVREventType(1801)
const VREvent_SpatialAnchors_RequestPoseUpdate = EVREventType(1802)
const VREvent_SpatialAnchors_RequestDescriptorUpdate = EVREventType(1803)
const VREvent_VendorSpecific_Reserved_Start = EVREventType(10000)
const VREvent_VendorSpecific_Reserved_End = EVREventType(19999)
const k_EDeviceActivityLevel_Unknown = EDeviceActivityLevel(-1)
const k_EDeviceActivityLevel_Idle = EDeviceActivityLevel(0)
const k_EDeviceActivityLevel_UserInteraction = EDeviceActivityLevel(1)
const k_EDeviceActivityLevel_UserInteraction_Timeout = EDeviceActivityLevel(2)
const k_EDeviceActivityLevel_Standby = EDeviceActivityLevel(3)
const k_EButton_System = EVRButtonId(0)
const k_EButton_ApplicationMenu = EVRButtonId(1)
const k_EButton_Grip = EVRButtonId(2)
const k_EButton_DPad_Left = EVRButtonId(3)
const k_EButton_DPad_Up = EVRButtonId(4)
const k_EButton_DPad_Right = EVRButtonId(5)
const k_EButton_DPad_Down = EVRButtonId(6)
const k_EButton_A = EVRButtonId(7)
const k_EButton_ProximitySensor = EVRButtonId(31)
const k_EButton_Axis0 = EVRButtonId(32)
const k_EButton_Axis1 = EVRButtonId(33)
const k_EButton_Axis2 = EVRButtonId(34)
const k_EButton_Axis3 = EVRButtonId(35)
const k_EButton_Axis4 = EVRButtonId(36)
const k_EButton_SteamVR_Touchpad = EVRButtonId(32)
const k_EButton_SteamVR_Trigger = EVRButtonId(33)
const k_EButton_Dashboard_Back = EVRButtonId(2)
const k_EButton_Max = EVRButtonId(64)
const VRMouseButton_Left = EVRMouseButton(1)
const VRMouseButton_Right = EVRMouseButton(2)
const VRMouseButton_Middle = EVRMouseButton(4)
const k_EDualAnalog_Left = EDualAnalogWhich(0)
const k_EDualAnalog_Right = EDualAnalogWhich(1)
const ShowUI_ControllerBinding = EShowUIType(0)
const ShowUI_ManageTrackers = EShowUIType(1)
const VRInputError_None = EVRInputError(0)
const VRInputError_NameNotFound = EVRInputError(1)
const VRInputError_WrongType = EVRInputError(2)
const VRInputError_InvalidHandle = EVRInputError(3)
const VRInputError_InvalidParam = EVRInputError(4)
const VRInputError_NoSteam = EVRInputError(5)
const VRInputError_MaxCapacityReached = EVRInputError(6)
const VRInputError_IPCError = EVRInputError(7)
const VRInputError_NoActiveActionSet = EVRInputError(8)
const VRInputError_InvalidDevice = EVRInputError(9)
const VRInputError_InvalidSkeleton = EVRInputError(10)
const VRInputError_InvalidBoneCount = EVRInputError(11)
const VRInputError_InvalidCompressedData = EVRInputError(12)
const VRInputError_NoData = EVRInputError(13)
const VRInputError_BufferTooSmall = EVRInputError(14)
const VRInputError_MismatchedActionManifest = EVRInputError(15)
const VRInputError_MissingSkeletonData = EVRInputError(16)
const VRInputError_InvalidBoneIndex = EVRInputError(17)
const VRSpatialAnchorError_Success = EVRSpatialAnchorError(0)
const VRSpatialAnchorError_Internal = EVRSpatialAnchorError(1)
const VRSpatialAnchorError_UnknownHandle = EVRSpatialAnchorError(2)
const VRSpatialAnchorError_ArrayTooSmall = EVRSpatialAnchorError(3)
const VRSpatialAnchorError_InvalidDescriptorChar = EVRSpatialAnchorError(4)
const VRSpatialAnchorError_NotYetAvailable = EVRSpatialAnchorError(5)
const VRSpatialAnchorError_NotAvailableInThisUniverse = EVRSpatialAnchorError(6)
const VRSpatialAnchorError_PermanentlyUnavailable = EVRSpatialAnchorError(7)
const VRSpatialAnchorError_WrongDriver = EVRSpatialAnchorError(8)
const VRSpatialAnchorError_DescriptorTooLong = EVRSpatialAnchorError(9)
const VRSpatialAnchorError_Unknown = EVRSpatialAnchorError(10)
const VRSpatialAnchorError_NoRoomCalibration = EVRSpatialAnchorError(11)
const VRSpatialAnchorError_InvalidArgument = EVRSpatialAnchorError(12)
const VRSpatialAnchorError_UnknownDriver = EVRSpatialAnchorError(13)
const k_eHiddenAreaMesh_Standard = EHiddenAreaMeshType(0)
const k_eHiddenAreaMesh_Inverse = EHiddenAreaMeshType(1)
const k_eHiddenAreaMesh_LineLoop = EHiddenAreaMeshType(2)
const k_eHiddenAreaMesh_Max = EHiddenAreaMeshType(3)
const k_eControllerAxis_None = EVRControllerAxisType(0)
const k_eControllerAxis_TrackPad = EVRControllerAxisType(1)
const k_eControllerAxis_Joystick = EVRControllerAxisType(2)
const k_eControllerAxis_Trigger = EVRControllerAxisType(3)
const ControllerEventOutput_OSEvents = EVRControllerEventOutputType(0)
const ControllerEventOutput_VREvents = EVRControllerEventOutputType(1)
const COLLISION_BOUNDS_STYLE_BEGINNER = ECollisionBoundsStyle(0)
const COLLISION_BOUNDS_STYLE_INTERMEDIATE = ECollisionBoundsStyle(1)
const COLLISION_BOUNDS_STYLE_SQUARES = ECollisionBoundsStyle(2)
const COLLISION_BOUNDS_STYLE_ADVANCED = ECollisionBoundsStyle(3)
const COLLISION_BOUNDS_STYLE_NONE = ECollisionBoundsStyle(4)
const COLLISION_BOUNDS_STYLE_COUNT = ECollisionBoundsStyle(5)
const VROverlayError_None = EVROverlayError(0)
const VROverlayError_UnknownOverlay = EVROverlayError(10)
const VROverlayError_InvalidHandle = EVROverlayError(11)
const VROverlayError_PermissionDenied = EVROverlayError(12)
const VROverlayError_OverlayLimitExceeded = EVROverlayError(13)
const VROverlayError_WrongVisibilityType = EVROverlayError(14)
const VROverlayError_KeyTooLong = EVROverlayError(15)
const VROverlayError_NameTooLong = EVROverlayError(16)
const VROverlayError_KeyInUse = EVROverlayError(17)
const VROverlayError_WrongTransformType = EVROverlayError(18)
const VROverlayError_InvalidTrackedDevice = EVROverlayError(19)
const VROverlayError_InvalidParameter = EVROverlayError(20)
const VROverlayError_ThumbnailCantBeDestroyed = EVROverlayError(21)
const VROverlayError_ArrayTooSmall = EVROverlayError(22)
const VROverlayError_RequestFailed = EVROverlayError(23)
const VROverlayError_InvalidTexture = EVROverlayError(24)
const VROverlayError_UnableToLoadFile = EVROverlayError(25)
const VROverlayError_KeyboardAlreadyInUse = EVROverlayError(26)
const VROverlayError_NoNeighbor = EVROverlayError(27)
const VROverlayError_TooManyMaskPrimitives = EVROverlayError(29)
const VROverlayError_BadMaskPrimitive = EVROverlayError(30)
const VROverlayError_TextureAlreadyLocked = EVROverlayError(31)
const VROverlayError_TextureLockCapacityReached = EVROverlayError(32)
const VROverlayError_TextureNotLocked = EVROverlayError(33)
const VRApplication_Other = EVRApplicationType(0)
const VRApplication_Scene = EVRApplicationType(1)
const VRApplication_Overlay = EVRApplicationType(2)
const VRApplication_Background = EVRApplicationType(3)
const VRApplication_Utility = EVRApplicationType(4)
const VRApplication_VRMonitor = EVRApplicationType(5)
const VRApplication_SteamWatchdog = EVRApplicationType(6)
const VRApplication_Bootstrapper = EVRApplicationType(7)
const VRApplication_WebHelper = EVRApplicationType(8)
const VRApplication_Max = EVRApplicationType(9)
const VRFirmwareError_None = EVRFirmwareError(0)
const VRFirmwareError_Success = EVRFirmwareError(1)
const VRFirmwareError_Fail = EVRFirmwareError(2)
const VRNotificationError_OK = EVRNotificationError(0)
const VRNotificationError_InvalidNotificationId = EVRNotificationError(100)
const VRNotificationError_NotificationQueueFull = EVRNotificationError(101)
const VRNotificationError_InvalidOverlayHandle = EVRNotificationError(102)
const VRNotificationError_SystemWithUserValueAlreadyExists = EVRNotificationError(103)
const VRSkeletalMotionRange_WithController = EVRSkeletalMotionRange(0)
const VRSkeletalMotionRange_WithoutController = EVRSkeletalMotionRange(1)
const VRSkeletalTracking_Estimated = EVRSkeletalTrackingLevel(0)
const VRSkeletalTracking_Partial = EVRSkeletalTrackingLevel(1)
const VRSkeletalTracking_Full = EVRSkeletalTrackingLevel(2)
const VRSkeletalTrackingLevel_Count = EVRSkeletalTrackingLevel(3)
const VRSkeletalTrackingLevel_Max = EVRSkeletalTrackingLevel(2)
const VRInitError_None = EVRInitError(0)
const VRInitError_Unknown = EVRInitError(1)
const VRInitError_Init_InstallationNotFound = EVRInitError(100)
const VRInitError_Init_InstallationCorrupt = EVRInitError(101)
const VRInitError_Init_VRClientDLLNotFound = EVRInitError(102)
const VRInitError_Init_FileNotFound = EVRInitError(103)
const VRInitError_Init_FactoryNotFound = EVRInitError(104)
const VRInitError_Init_InterfaceNotFound = EVRInitError(105)
const VRInitError_Init_InvalidInterface = EVRInitError(106)
const VRInitError_Init_UserConfigDirectoryInvalid = EVRInitError(107)
const VRInitError_Init_HmdNotFound = EVRInitError(108)
const VRInitError_Init_NotInitialized = EVRInitError(109)
const VRInitError_Init_PathRegistryNotFound = EVRInitError(110)
const VRInitError_Init_NoConfigPath = EVRInitError(111)
const VRInitError_Init_NoLogPath = EVRInitError(112)
const VRInitError_Init_PathRegistryNotWritable = EVRInitError(113)
const VRInitError_Init_AppInfoInitFailed = EVRInitError(114)
const VRInitError_Init_Retry = EVRInitError(115)
const VRInitError_Init_InitCanceledByUser = EVRInitError(116)
const VRInitError_Init_AnotherAppLaunching = EVRInitError(117)
const VRInitError_Init_SettingsInitFailed = EVRInitError(118)
const VRInitError_Init_ShuttingDown = EVRInitError(119)
const VRInitError_Init_TooManyObjects = EVRInitError(120)
const VRInitError_Init_NoServerForBackgroundApp = EVRInitError(121)
const VRInitError_Init_NotSupportedWithCompositor = EVRInitError(122)
const VRInitError_Init_NotAvailableToUtilityApps = EVRInitError(123)
const VRInitError_Init_Internal = EVRInitError(124)
const VRInitError_Init_HmdDriverIdIsNone = EVRInitError(125)
const VRInitError_Init_HmdNotFoundPresenceFailed = EVRInitError(126)
const VRInitError_Init_VRMonitorNotFound = EVRInitError(127)
const VRInitError_Init_VRMonitorStartupFailed = EVRInitError(128)
const VRInitError_Init_LowPowerWatchdogNotSupported = EVRInitError(129)
const VRInitError_Init_InvalidApplicationType = EVRInitError(130)
const VRInitError_Init_NotAvailableToWatchdogApps = EVRInitError(131)
const VRInitError_Init_WatchdogDisabledInSettings = EVRInitError(132)
const VRInitError_Init_VRDashboardNotFound = EVRInitError(133)
const VRInitError_Init_VRDashboardStartupFailed = EVRInitError(134)
const VRInitError_Init_VRHomeNotFound = EVRInitError(135)
const VRInitError_Init_VRHomeStartupFailed = EVRInitError(136)
const VRInitError_Init_RebootingBusy = EVRInitError(137)
const VRInitError_Init_FirmwareUpdateBusy = EVRInitError(138)
const VRInitError_Init_FirmwareRecoveryBusy = EVRInitError(139)
const VRInitError_Init_USBServiceBusy = EVRInitError(140)
const VRInitError_Init_VRWebHelperStartupFailed = EVRInitError(141)
const VRInitError_Init_TrackerManagerInitFailed = EVRInitError(142)
const VRInitError_Driver_Failed = EVRInitError(200)
const VRInitError_Driver_Unknown = EVRInitError(201)
const VRInitError_Driver_HmdUnknown = EVRInitError(202)
const VRInitError_Driver_NotLoaded = EVRInitError(203)
const VRInitError_Driver_RuntimeOutOfDate = EVRInitError(204)
const VRInitError_Driver_HmdInUse = EVRInitError(205)
const VRInitError_Driver_NotCalibrated = EVRInitError(206)
const VRInitError_Driver_CalibrationInvalid = EVRInitError(207)
const VRInitError_Driver_HmdDisplayNotFound = EVRInitError(208)
const VRInitError_Driver_TrackedDeviceInterfaceUnknown = EVRInitError(209)
const VRInitError_Driver_HmdDriverIdOutOfBounds = EVRInitError(211)
const VRInitError_Driver_HmdDisplayMirrored = EVRInitError(212)
const VRInitError_IPC_ServerInitFailed = EVRInitError(300)
const VRInitError_IPC_ConnectFailed = EVRInitError(301)
const VRInitError_IPC_SharedStateInitFailed = EVRInitError(302)
const VRInitError_IPC_CompositorInitFailed = EVRInitError(303)
const VRInitError_IPC_MutexInitFailed = EVRInitError(304)
const VRInitError_IPC_Failed = EVRInitError(305)
const VRInitError_IPC_CompositorConnectFailed = EVRInitError(306)
const VRInitError_IPC_CompositorInvalidConnectResponse = EVRInitError(307)
const VRInitError_IPC_ConnectFailedAfterMultipleAttempts = EVRInitError(308)
const VRInitError_Compositor_Failed = EVRInitError(400)
const VRInitError_Compositor_D3D11HardwareRequired = EVRInitError(401)
const VRInitError_Compositor_FirmwareRequiresUpdate = EVRInitError(402)
const VRInitError_Compositor_OverlayInitFailed = EVRInitError(403)
const VRInitError_Compositor_ScreenshotsInitFailed = EVRInitError(404)
const VRInitError_Compositor_UnableToCreateDevice = EVRInitError(405)
const VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = EVRInitError(1000)
const VRInitError_VendorSpecific_WindowsNotInDevMode = EVRInitError(1001)
const VRInitError_VendorSpecific_HmdFound_CantOpenDevice = EVRInitError(1101)
const VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = EVRInitError(1102)
const VRInitError_VendorSpecific_HmdFound_NoStoredConfig = EVRInitError(1103)
const VRInitError_VendorSpecific_HmdFound_ConfigTooBig = EVRInitError(1104)
const VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = EVRInitError(1105)
const VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = EVRInitError(1106)
const VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = EVRInitError(1107)
const VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = EVRInitError(1108)
const VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = EVRInitError(1109)
const VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = EVRInitError(1110)
const VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = EVRInitError(1111)
const VRInitError_VendorSpecific_HmdFound_UserDataError = EVRInitError(1112)
const VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = EVRInitError(1113)
const VRInitError_Steam_SteamInstallationNotFound = EVRInitError(2000)
const VRScreenshotType_None = EVRScreenshotType(0)
const VRScreenshotType_Mono = EVRScreenshotType(1)
const VRScreenshotType_Stereo = EVRScreenshotType(2)
const VRScreenshotType_Cubemap = EVRScreenshotType(3)
const VRScreenshotType_MonoPanorama = EVRScreenshotType(4)
const VRScreenshotType_StereoPanorama = EVRScreenshotType(5)
const VRScreenshotPropertyFilenames_Preview = EVRScreenshotPropertyFilenames(0)
const VRScreenshotPropertyFilenames_VR = EVRScreenshotPropertyFilenames(1)
const VRTrackedCameraError_None = EVRTrackedCameraError(0)
const VRTrackedCameraError_OperationFailed = EVRTrackedCameraError(100)
const VRTrackedCameraError_InvalidHandle = EVRTrackedCameraError(101)
const VRTrackedCameraError_InvalidFrameHeaderVersion = EVRTrackedCameraError(102)
const VRTrackedCameraError_OutOfHandles = EVRTrackedCameraError(103)
const VRTrackedCameraError_IPCFailure = EVRTrackedCameraError(104)
const VRTrackedCameraError_NotSupportedForThisDevice = EVRTrackedCameraError(105)
const VRTrackedCameraError_SharedMemoryFailure = EVRTrackedCameraError(106)
const VRTrackedCameraError_FrameBufferingFailure = EVRTrackedCameraError(107)
const VRTrackedCameraError_StreamSetupFailure = EVRTrackedCameraError(108)
const VRTrackedCameraError_InvalidGLTextureId = EVRTrackedCameraError(109)
const VRTrackedCameraError_InvalidSharedTextureHandle = EVRTrackedCameraError(110)
const VRTrackedCameraError_FailedToGetGLTextureId = EVRTrackedCameraError(111)
const VRTrackedCameraError_SharedTextureFailure = EVRTrackedCameraError(112)
const VRTrackedCameraError_NoFrameAvailable = EVRTrackedCameraError(113)
const VRTrackedCameraError_InvalidArgument = EVRTrackedCameraError(114)
const VRTrackedCameraError_InvalidFrameBufferSize = EVRTrackedCameraError(115)
const EVRTrackedCameraFrameLayout_Mono = EVRTrackedCameraFrameLayout(1)
const EVRTrackedCameraFrameLayout_Stereo = EVRTrackedCameraFrameLayout(2)
const EVRTrackedCameraFrameLayout_VerticalLayout = EVRTrackedCameraFrameLayout(16)
const EVRTrackedCameraFrameLayout_HorizontalLayout = EVRTrackedCameraFrameLayout(32)
const VRTrackedCameraFrameType_Distorted = EVRTrackedCameraFrameType(0)
const VRTrackedCameraFrameType_Undistorted = EVRTrackedCameraFrameType(1)
const VRTrackedCameraFrameType_MaximumUndistorted = EVRTrackedCameraFrameType(2)
const MAX_CAMERA_FRAME_TYPES = EVRTrackedCameraFrameType(3)
const VRDistortionFunctionType_None = EVRDistortionFunctionType(0)
const VRDistortionFunctionType_FTheta = EVRDistortionFunctionType(1)
const MAX_DISTORTION_FUNCTION_TYPES = EVRDistortionFunctionType(3)
const VSync_None = EVSync(0)
const VSync_WaitRender = EVSync(1)
const VSync_NoWaitRender = EVSync(2)
const EVRMuraCorrectionMode_Default = EVRMuraCorrectionMode(0)
const EVRMuraCorrectionMode_NoCorrection = EVRMuraCorrectionMode(1)
const OffScale_AccelX = Imu_OffScaleFlags(1)
const OffScale_AccelY = Imu_OffScaleFlags(2)
const OffScale_AccelZ = Imu_OffScaleFlags(4)
const OffScale_GyroX = Imu_OffScaleFlags(8)
const OffScale_GyroY = Imu_OffScaleFlags(16)
const OffScale_GyroZ = Imu_OffScaleFlags(32)
const VRApplicationError_None = EVRApplicationError(0)
const VRApplicationError_AppKeyAlreadyExists = EVRApplicationError(100)
const VRApplicationError_NoManifest = EVRApplicationError(101)
const VRApplicationError_NoApplication = EVRApplicationError(102)
const VRApplicationError_InvalidIndex = EVRApplicationError(103)
const VRApplicationError_UnknownApplication = EVRApplicationError(104)
const VRApplicationError_IPCFailed = EVRApplicationError(105)
const VRApplicationError_ApplicationAlreadyRunning = EVRApplicationError(106)
const VRApplicationError_InvalidManifest = EVRApplicationError(107)
const VRApplicationError_InvalidApplication = EVRApplicationError(108)
const VRApplicationError_LaunchFailed = EVRApplicationError(109)
const VRApplicationError_ApplicationAlreadyStarting = EVRApplicationError(110)
const VRApplicationError_LaunchInProgress = EVRApplicationError(111)
const VRApplicationError_OldApplicationQuitting = EVRApplicationError(112)
const VRApplicationError_TransitionAborted = EVRApplicationError(113)
const VRApplicationError_IsTemplate = EVRApplicationError(114)
const VRApplicationError_SteamVRIsExiting = EVRApplicationError(115)
const VRApplicationError_BufferTooSmall = EVRApplicationError(200)
const VRApplicationError_PropertyNotSet = EVRApplicationError(201)
const VRApplicationError_UnknownProperty = EVRApplicationError(202)
const VRApplicationError_InvalidParameter = EVRApplicationError(203)
const VRApplicationProperty_Name_String = EVRApplicationProperty(0)
const VRApplicationProperty_LaunchType_String = EVRApplicationProperty(11)
const VRApplicationProperty_WorkingDirectory_String = EVRApplicationProperty(12)
const VRApplicationProperty_BinaryPath_String = EVRApplicationProperty(13)
const VRApplicationProperty_Arguments_String = EVRApplicationProperty(14)
const VRApplicationProperty_URL_String = EVRApplicationProperty(15)
const VRApplicationProperty_Description_String = EVRApplicationProperty(50)
const VRApplicationProperty_NewsURL_String = EVRApplicationProperty(51)
const VRApplicationProperty_ImagePath_String = EVRApplicationProperty(52)
const VRApplicationProperty_Source_String = EVRApplicationProperty(53)
const VRApplicationProperty_ActionManifestURL_String = EVRApplicationProperty(54)
const VRApplicationProperty_IsDashboardOverlay_Bool = EVRApplicationProperty(60)
const VRApplicationProperty_IsTemplate_Bool = EVRApplicationProperty(61)
const VRApplicationProperty_IsInstanced_Bool = EVRApplicationProperty(62)
const VRApplicationProperty_IsInternal_Bool = EVRApplicationProperty(63)
const VRApplicationProperty_WantsCompositorPauseInStandby_Bool = EVRApplicationProperty(64)
const VRApplicationProperty_LastLaunchTime_Uint64 = EVRApplicationProperty(70)
const VRSettingsError_None = EVRSettingsError(0)
const VRSettingsError_IPCFailed = EVRSettingsError(1)
const VRSettingsError_WriteFailed = EVRSettingsError(2)
const VRSettingsError_ReadFailed = EVRSettingsError(3)
const VRSettingsError_JsonParseFailed = EVRSettingsError(4)
const VRSettingsError_UnsetSettingHasNoDefault = EVRSettingsError(5)
const ChaperoneCalibrationState_OK = ChaperoneCalibrationState(1)
const ChaperoneCalibrationState_Warning = ChaperoneCalibrationState(100)
const ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = ChaperoneCalibrationState(101)
const ChaperoneCalibrationState_Warning_BaseStationRemoved = ChaperoneCalibrationState(102)
const ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = ChaperoneCalibrationState(103)
const ChaperoneCalibrationState_Error = ChaperoneCalibrationState(200)
const ChaperoneCalibrationState_Error_BaseStationUninitialized = ChaperoneCalibrationState(201)
const ChaperoneCalibrationState_Error_BaseStationConflict = ChaperoneCalibrationState(202)
const ChaperoneCalibrationState_Error_PlayAreaInvalid = ChaperoneCalibrationState(203)
const ChaperoneCalibrationState_Error_CollisionBoundsInvalid = ChaperoneCalibrationState(204)
const EChaperoneConfigFile_Live = EChaperoneConfigFile(1)
const EChaperoneConfigFile_Temp = EChaperoneConfigFile(2)
const EChaperoneImport_BoundsOnly = EChaperoneImportFlags(1)
const VRCompositorError_None = EVRCompositorError(0)
const VRCompositorError_RequestFailed = EVRCompositorError(1)
const VRCompositorError_IncompatibleVersion = EVRCompositorError(100)
const VRCompositorError_DoNotHaveFocus = EVRCompositorError(101)
const VRCompositorError_InvalidTexture = EVRCompositorError(102)
const VRCompositorError_IsNotSceneApplication = EVRCompositorError(103)
const VRCompositorError_TextureIsOnWrongDevice = EVRCompositorError(104)
const VRCompositorError_TextureUsesUnsupportedFormat = EVRCompositorError(105)
const VRCompositorError_SharedTexturesNotSupported = EVRCompositorError(106)
const VRCompositorError_IndexOutOfRange = EVRCompositorError(107)
const VRCompositorError_AlreadySubmitted = EVRCompositorError(108)
const VRCompositorError_InvalidBounds = EVRCompositorError(109)
const VRCompositorTimingMode_Implicit = EVRCompositorTimingMode(0)
const VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = EVRCompositorTimingMode(1)
const VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = EVRCompositorTimingMode(2)
const EVRNotificationType_Transient = EVRNotificationType(0)
const EVRNotificationType_Persistent = EVRNotificationType(1)
const EVRNotificationType_Transient_SystemWithUserValue = EVRNotificationType(2)
const EVRNotificationStyle_None = EVRNotificationStyle(0)
const EVRNotificationStyle_Application = EVRNotificationStyle(100)
const EVRNotificationStyle_Contact_Disabled = EVRNotificationStyle(200)
const EVRNotificationStyle_Contact_Enabled = EVRNotificationStyle(201)
const EVRNotificationStyle_Contact_Active = EVRNotificationStyle(202)
const VROverlayInputMethod_None = VROverlayInputMethod(0)
const VROverlayInputMethod_Mouse = VROverlayInputMethod(1)
const VROverlayInputMethod_DualAnalog = VROverlayInputMethod(2)
const VROverlayTransform_Absolute = VROverlayTransformType(0)
const VROverlayTransform_TrackedDeviceRelative = VROverlayTransformType(1)
const VROverlayTransform_SystemOverlay = VROverlayTransformType(2)
const VROverlayTransform_TrackedComponent = VROverlayTransformType(3)
const VRMessageOverlayResponse_ButtonPress_0 = VRMessageOverlayResponse(0)
const VRMessageOverlayResponse_ButtonPress_1 = VRMessageOverlayResponse(1)
const VRMessageOverlayResponse_ButtonPress_2 = VRMessageOverlayResponse(2)
const VRMessageOverlayResponse_ButtonPress_3 = VRMessageOverlayResponse(3)
const VRMessageOverlayResponse_CouldntFindSystemOverlay = VRMessageOverlayResponse(4)
const VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = VRMessageOverlayResponse(5)
const VRMessageOverlayResponse_ApplicationQuit = VRMessageOverlayResponse(6)
const k_EGamepadTextInputModeNormal = EGamepadTextInputMode(0)
const k_EGamepadTextInputModePassword = EGamepadTextInputMode(1)
const k_EGamepadTextInputModeSubmit = EGamepadTextInputMode(2)
const k_EGamepadTextInputLineModeSingleLine = EGamepadTextInputLineMode(0)
const k_EGamepadTextInputLineModeMultipleLines = EGamepadTextInputLineMode(1)
const OverlayIntersectionPrimitiveType_Rectangle = EVROverlayIntersectionMaskPrimitiveType(0)
const OverlayIntersectionPrimitiveType_Circle = EVROverlayIntersectionMaskPrimitiveType(1)
const VRRenderModelError_None = EVRRenderModelError(0)
const VRRenderModelError_Loading = EVRRenderModelError(100)
const VRRenderModelError_NotSupported = EVRRenderModelError(200)
const VRRenderModelError_InvalidArg = EVRRenderModelError(300)
const VRRenderModelError_InvalidModel = EVRRenderModelError(301)
const VRRenderModelError_NoShapes = EVRRenderModelError(302)
const VRRenderModelError_MultipleShapes = EVRRenderModelError(303)
const VRRenderModelError_TooManyVertices = EVRRenderModelError(304)
const VRRenderModelError_MultipleTextures = EVRRenderModelError(305)
const VRRenderModelError_BufferTooSmall = EVRRenderModelError(306)
const VRRenderModelError_NotEnoughNormals = EVRRenderModelError(307)
const VRRenderModelError_NotEnoughTexCoords = EVRRenderModelError(308)
const VRRenderModelError_InvalidTexture = EVRRenderModelError(400)
const VRComponentProperty_IsStatic = EVRComponentProperty(1)
const VRComponentProperty_IsVisible = EVRComponentProperty(2)
const VRComponentProperty_IsTouched = EVRComponentProperty(4)
const VRComponentProperty_IsPressed = EVRComponentProperty(8)
const VRComponentProperty_IsScrolled = EVRComponentProperty(16)
const VRScreenshotError_None = EVRScreenshotError(0)
const VRScreenshotError_RequestFailed = EVRScreenshotError(1)
const VRScreenshotError_IncompatibleVersion = EVRScreenshotError(100)
const VRScreenshotError_NotFound = EVRScreenshotError(101)
const VRScreenshotError_BufferTooSmall = EVRScreenshotError(102)
const VRScreenshotError_ScreenshotAlreadyInProgress = EVRScreenshotError(108)
const VRSkeletalTransformSpace_Model = EVRSkeletalTransformSpace(0)
const VRSkeletalTransformSpace_Parent = EVRSkeletalTransformSpace(1)
const VRSkeletalReferencePose_BindPose = EVRSkeletalReferencePose(0)
const VRSkeletalReferencePose_OpenHand = EVRSkeletalReferencePose(1)
const VRSkeletalReferencePose_Fist = EVRSkeletalReferencePose(2)
const VRSkeletalReferencePose_GripLimit = EVRSkeletalReferencePose(3)
const VRFinger_Thumb = EVRFinger(0)
const VRFinger_Index = EVRFinger(1)
const VRFinger_Middle = EVRFinger(2)
const VRFinger_Ring = EVRFinger(3)
const VRFinger_Pinky = EVRFinger(4)
const VRFinger_Count = EVRFinger(5)
const VRFingerSplay_Thumb_Index = EVRFingerSplay(0)
const VRFingerSplay_Index_Middle = EVRFingerSplay(1)
const VRFingerSplay_Middle_Ring = EVRFingerSplay(2)
const VRFingerSplay_Ring_Pinky = EVRFingerSplay(3)
const VRFingerSplay_Count = EVRFingerSplay(4)
const VRInputFilterCancel_Timers = EVRInputFilterCancelType(0)
const VRInputFilterCancel_Momentum = EVRInputFilterCancelType(1)
const VRInputString_Hand = EVRInputStringBits(1)
const VRInputString_ControllerType = EVRInputStringBits(2)
const VRInputString_InputSource = EVRInputStringBits(4)
const VRInputString_All = EVRInputStringBits(4294967295)
const IOBuffer_Success = EIOBufferError(0)
const IOBuffer_OperationFailed = EIOBufferError(100)
const IOBuffer_InvalidHandle = EIOBufferError(101)
const IOBuffer_InvalidArgument = EIOBufferError(102)
const IOBuffer_PathExists = EIOBufferError(103)
const IOBuffer_PathDoesNotExist = EIOBufferError(104)
const IOBuffer_Permission = EIOBufferError(105)
const IOBufferMode_Read = EIOBufferMode(1)
const IOBufferMode_Write = EIOBufferMode(2)
const IOBufferMode_Create = EIOBufferMode(512)


text:
using JacobiSVD
using LinearAlgebra
using Test, Random

Random.seed!(1101)

#=
Ground rules:
These are mostly checks of sanity and API consistency;
correctness is up to LAPACK implementors.
=#

# construct a general matrix with specified singular values
function mkmat(m,n,s,T)
    @assert length(s) == n
    @assert n <= m
    if T <: Complex
        tmp1 = randn(m,n) + randn(m,n)*1im
        tmp2 = randn(n,n) + randn(n,n)*1im
    else
        tmp1 = randn(m,n)
        tmp2 = randn(n,n)
    end
    u,r = qr(tmp1)
    v,r = qr(tmp2)
    Atmp = u * diagm(0=>s) * v'
    A = T.(Atmp)
end

# TODO:
@testset "jsvd interface $T" for T in (Float64, ComplexF64)
    tol = 10.0
    e = eps(real(T))
    m,n = 10,5
    s = rand(n) .+ 1.0
    A = mkmat(m,n,s,T)
    S = jsvd!(copy(A))
    @test norm(S.U * Diagonal(S.S) * S.Vt - A) / norm(A) < tol * m * e
    At = Matrix(A')
    S = jsvd!(copy(At))
    @test norm(S.U * Diagonal(S.S) * S.Vt - At) / norm(A) < tol * m * e
end

@testset "Squat $T" for T in (Float64, ComplexF64)
    m,n = 50,100
    A = rand(T,m,n)
    @test_throws ArgumentError gejsv!('G','U','V',copy(A))
    @test_throws ArgumentError gesvj!('G','U','V',copy(A))
end

@testset "Tall easy $T" for T in (Float64, ComplexF64)
    m,n = 100,50
    s = rand(n) .+ 1.0
    A = mkmat(m,n,s,T)
    U, S, V, scales, sconda = gejsv!('G','U','V',copy(A))
    tol = 10.0
    Ss = (scales[2] / scales[1]) * S
    e = eps(real(T))
    @test norm(U * Diagonal(Ss) * V' - A) / norm(A) < tol * m * e
    @test norm(U' * U - I) < tol * m * e
    @test norm(V' * V - I) < tol * m * e

    U, S, V, scale = gesvj!('G','U','V',copy(A))
    @test norm(U * Diagonal(scale * S) * V' - A) / norm(A) < tol * m * e
    @test norm(U' * U - I) < tol * m * e
    @test norm(V' * V - I) < tol * m * e
end

@testset "Tall serious $T" for T in (Float32, ComplexF32)
    m,n = 100,50
    r = -1.5 * log2(eps(real(T)))
    s = rand(n) .+ 1.0
    # make a challenging mtx with guaranteed:
    c = 2.0 .^ collect(range(0.0,stop=r,length=n))
    A = mkmat(m,n,s,T) * Diagonal(shuffle(T.(c)))
    Tw = widen(T)
    # could use
    #    Uw, Sw, Vw = svd(Tw.(A))
    # but we demonstrated basic sanity above
    Uw, Sw, Vw, scalew = gesvj!('G','U','V',Tw.(A))
    Sw .= scalew .* Sw
    U, S, V, scales, sconda = gejsv!('G','U','V',copy(A))
    tol = 10.0
    Ss = (scales[2] / scales[1]) * S
    e = eps(real(T))
    @test norm(U * Diagonal(Ss) * V' - A) / norm(A) < tol * m * e
    @test norm(U' * U - I) < tol * m * e
    @test norm(V' * V - I) < tol * m * e
    Sss = sort(Ss, rev=true)
    Twr = real(Tw)
    # the factor of m is a WAG here
    @test all((Twr.(Sss) - Sw) ./ Sw .< tol * m * e)

    U, S, V, scale = gesvj!('G','U','V',copy(A))
    @test norm(U * Diagonal(scale*S) * V' - A) / norm(A) < tol * m * e
    @test norm(U' * U - I) < tol * m * e
    @test norm(V' * V - I) < tol * m * e
    Sss = sort(S, rev=true)
    # the factor of m is a WAG here
    @test all((Twr.(Sss) - Sw) ./ Sw .< tol * m * e)
end

# Attempt to avoid surprises with unusual job params.
# This is intended to make sure we allocate correctly sized arrays etc.
@testset "SVJ jobs $T" for T in (Float32, ComplexF32)
    m,n = 10,5
    s = rand(n) .+ 1.0
    A = mkmat(m,n,s,T)
    sref = svdvals(A)
    for (joba, jobu, jobv) in
        (('G','U','V'),
         ('G','C','V'),
         ('G','N','N'),
         ('G','U','N'),
         ('G','N','V')
         )
        U, S, V, scale = gesvj!(joba,jobu,jobv,copy(A),ctol=m)
        Ss = sort(scale * S, rev=true)
        @test Ss ≈ sref
    end
    V0 = rand(T,2,n)
    for (joba, jobu, jobv) in
        (('G','U','A'),
         ('G','C','A'),
         ('G','N','A')
         )
        U, S, V, scale = gesvj!(joba,jobu,jobv,copy(A),Vinit=V0,ctol=m)
        Ss = sort(scale * S, rev=true)
        @test Ss ≈ sref
    end
    # TODO: triangular A (joba ∈ L,U)
end

@testset "JSV jobs $T" for T in (Float32, ComplexF32)
    m,n = 10,5
    s = rand(n) .+ 1.0
    A = mkmat(m,n,s,T)
    sref = svdvals(A)
    for (joba, jobu, jobv) in
        (('F','U','V'),
         ('C','U','V'),
         ('E','U','V'),
         ('G','U','V'),
         ('A','U','V'),
         ('R','U','V'),
         ('F','U','N'),
         ('F','F','V'),
         ('F','N','V'),
         )
        U, S, V, scales, sconda = gejsv!(joba,jobu,jobv,copy(A))
        Ss = sort((scales[2]/scales[1]) * S, rev=true)
        @test Ss ≈ sref
        if jobu == 'F'
            @test size(U) == (m,m)
        elseif jobu == 'U'
            @test size(U) == (m,n)
        end
        if joba ∈ ('E','G')
            @test sconda >= 0
        else
            @test sconda == -1
        end
    end
end
@testset "JSV perturb jobs $T" for T in (Float32, ComplexF32)
    m,n = 10,5
    s = rand(n) .+ 1.0
    A = mkmat(m,n,s,T)
    sref = svdvals(A)
    for (joba, jobu, jobv) in
        (('F','U','V'),
         ('F','N','N'),
         )
        # perturb to avoid denorms
        U, S, V, scales, sconda = gejsv!(joba,jobu,jobv,copy(A),jobp='P')
        Ss = sort((scales[2]/scales[1]) * S, rev=true)
        @test Ss ≈ sref
    end
end

@testset "JSV unrestricted jobs $T" for T in (Float32, ComplexF32)
    m,n = 10,5
    s = rand(n) .+ 1.0
    A = mkmat(m,n,s,T)
    sref = svdvals(A)
    for (joba, jobu, jobv) in
        (('F','U','V'),
         ('F','N','N'),
         )
        # don't restrict range
        U, S, V, scales, sconda = gejsv!(joba,jobu,jobv,copy(A),jobr='N')
        Ss = sort((scales[2]/scales[1]) * S, rev=true)
        @test Ss ≈ sref
    end
end

@testset "JSV transposable jobs $T" for T in (Float32, ComplexF32)
    m,n = 10,5
    # transpose obvs requires square A
    s = rand(m) .+ 1.0
    A = mkmat(m,m,s,T)
    sref = svdvals(A)
    for (joba, jobu, jobv) in
        (('F','U','V'),
         ('F','N','N'),
         ('F','W','V'),
         ('F','U','W')
         )
        U, S, V, scales, sconda = gejsv!(joba,jobu,jobv,copy(A),jobt='T')
        Ss = sort((scales[2]/scales[1]) * S, rev=true)
        @test Ss ≈ sref
    end
end

ext: jl


text:
"""
    Module Basis3DHex

Includes DG core functions.
"""

module Basis3DHex

export vandermonde_3D, grad_vandermonde_3D
export nodes_3D, equi_nodes_3D, quad_nodes_3D

using Basis1D
using CommonUtils
using LinearAlgebra

"""
    vandermonde_2D(N, r)

Initialize the 2D Vandermonde matrix of order N "Legendre" polynomials at
nodes (r,s)

# Examples
```jldoctest
"""
function vandermonde_3D(N, r, s, t)

    Np = convert(Int,(N+1)^3)
    sk = 1
    V = zeros(length(r), Np);
    for i=0:N
        for j=0:N
            for k=0:N
                V[:,sk] = jacobiP(r, 0, 0, i).*jacobiP(s, 0, 0, j).*jacobiP(t, 0, 0, k)
                sk += 1
            end
        end
    end
    return V
end

"""
    grad_vandermonde_3D(N, r, s, t)

# Examples
```jldoctest
"""
function grad_vandermonde_3D(N, r, s, t)

    Np = convert(Int,(N+1)^3)
    sk = 1
    Vr = zeros(length(r), Np);
    Vs = zeros(length(r), Np);
    Vt = zeros(length(r), Np);
    for i=0:N
        for j=0:N
            for k=0:N
                Vr[:,sk] = grad_jacobiP(r, 0, 0, i).*jacobiP(s, 0, 0, j).*jacobiP(t,0,0,k)
                Vs[:,sk] = jacobiP(r, 0, 0, i).*grad_jacobiP(s, 0, 0, j).*jacobiP(t,0,0,k)
                Vt[:,sk] = jacobiP(r, 0, 0, i).*jacobiP(s, 0, 0, j).*grad_jacobiP(t,0,0,k)
                sk += 1
            end
        end
    end

    return Vr, Vs, Vt
end

# ===================================================

"""
    nodes_3D(N)

# Examples
```jldoctest
"""

function nodes_3D(N)
    r1D,w1D = gauss_lobatto_quad(0,0,N)
    return vec.(meshgrid(r1D,r1D,r1D))
end

"""
    equi_nodes_3D(N)

Compute optimized interpolation nodes using blend & warp method on equilateral
triangles for polynomial of order N, with Np points

# Examples
```jldoctest
"""

function equi_nodes_3D(N)
    r1D = LinRange(-1,1,N+1)
    return vec.(meshgrid(r1D,r1D,r1D))
end

"""
    quad_nodes_3D(N)

# Examples
```jldoctest
"""

function quad_nodes_3D(N)
    r1D,w1D = gauss_quad(0,0,N)
    r,s,t = vec.(meshgrid(r1D,r1D,r1D))
    wr,ws,wt = vec.(meshgrid(w1D,w1D,w1D))
    w = @. wr*ws*wt
    return r,s,t,w
end

end

max_stars_repo_name: jlchan/ESDG-CNS

max_issues_repo_name: jlchan/ESDG-CNS

max_forks_repo_name: jlchan/ESDG-CNS


text:
"""
Each Tuple corresponds to (con_name, internal_index, moi_index)
"""
function get_all_constraint_index(model::OperationModel)
    con_index = Vector{Tuple{ConstraintKey, Int, Int}}()
    container = get_optimization_container(model)
    for (key, value) in get_constraints(container)
        for (idx, constraint) in enumerate(value)
            moi_index = JuMP.optimizer_index(constraint)
            push!(con_index, (key, idx, moi_index.value))
        end
    end
    return con_index
end

"""
Each Tuple corresponds to (con_name, internal_index, moi_index)
"""
function get_all_variable_index(model::OperationModel)
    var_keys = get_all_variable_keys(model)
    return [(encode_key(v[1]), v[2], v[3]) for v in var_keys]
end

function get_all_variable_keys(model::OperationModel)
    var_index = Vector{Tuple{VariableKey, Int, Int}}()
    container = get_optimization_container(model)
    for (key, value) in get_variables(container)
        for (idx, variable) in enumerate(value)
            moi_index = JuMP.optimizer_index(variable)
            push!(var_index, (key, idx, moi_index.value))
        end
    end
    return var_index
end

function get_constraint_index(model::OperationModel, index::Int)
    container = get_optimization_container(model)
    constraints = get_constraints(container)
    for i in get_all_constraint_index(model)
        if i[3] == index
            return constraints[i[1]].data[i[2]]
        end
    end
    @info "Index not found"
    return
end

function get_variable_index(model::OperationModel, index::Int)
    container = get_optimization_container(model)
    variables = get_variables(container)
    for i in get_all_variable_keys(model)
        if i[3] == index
            return variables[i[1]].data[i[2]]
        end
    end
    @info "Index not found"
    return
end

function get_detailed_constraint_numerical_bounds(model::OperationModel)
    if !is_built(model)
        error("Model not built, can't calculate constraint numerical bounds")
    end
    constraint_bounds = Dict()
    for (const_key, constriant_array) in get_constraints(get_optimization_container(model))
        if isa(constriant_array, SparseAxisArray)
            bounds = ConstraintBounds()
            for idx in eachindex(constriant_array)
                constriant_array[idx] == 0.0 && continue
                con_obj = JuMP.constraint_object(constriant_array[idx])
                update_coefficient_bounds(bounds, con_obj, idx)
                update_rhs_bounds(bounds, con_obj, idx)
            end
            constraint_bounds[const_key] = bounds
        else
            bounds = ConstraintBounds()
            for idx in Iterators.product(constriant_array.axes...)
                con_obj = JuMP.constraint_object(constriant_array[idx...])
                update_coefficient_bounds(bounds, con_obj, idx)
                update_rhs_bounds(bounds, con_obj, idx)
            end
            constraint_bounds[const_key] = bounds
        end
    end
    return constraint_bounds
end

function get_detailed_variable_numerical_bounds(model::OperationModel)
    if !is_built(model)
        error("Model not built, can't calculate variable numerical bounds")
    end
    variable_bounds = Dict()
    for (variable_key, variable_array) in get_variables(get_optimization_container(model))
        bounds = VariableBounds()
        if isa(variable_array, SparseAxisArray)
            for idx in eachindex(variable_array)
                var = variable_array[idx]
                var == 0.0 && continue
                update_variable_bounds(bounds, var, idx)
            end
        else
            for idx in Iterators.product(variable_array.axes...)
                var = variable_array[idx...]
                update_variable_bounds(bounds, var, idx)
            end
        end
        variable_bounds[variable_key] = bounds
    end
    return variable_bounds
end


text:
@testset "forward sampling 1" begin
    results = forward_sampling(plate_program!; params = (rand(10),), num_iterations=100)
    @test results.interpretation == Forward()
    log_rate = results[:log_rate]
    @info "Mean log rate = $(mean(log_rate))"
end


text:
module Http

using HTTP

abstract type HttpClient end

post(::HttpClient, uri::String, body::String) = error("Implement post in HttpClient subtypes")

struct RealHttpClient <: HttpClient end

function post(::RealHttpClient, uri::String, body::String)
    HTTP.request("POST", uri, [], body)

    nothing
end

export HttpClient, post
export RealHttpClient

end


text:
module TestConstructors
    using Base.Test
    using NullableArrays

    # test Inner Constructor
    @test_throws ArgumentError NullableArray([1, 2, 3, 4], [true, false, true])

    # test (A::AbstractArray, m::Array{Bool}) constructor
    v = [1, 2, 3, 4]
    dv = NullableArray(v, fill(false, size(v)))

    m = [1 2; 3 4]
    dm = NullableArray(m, fill(false, size(m)))

    t = Array(Int, 2, 2, 2)
    t[1:2, 1:2, 1:2] = 1

    dt = NullableArray(t, fill(false, size(t)))
    dv = NullableArray(v, [false, false, false, false])

    y2 = NullableArray([1, 2, 3, 4, 5, 6],
                       [true, false, false, false, false ,false])
    @test isa(y2, NullableVector{Int})
    @test y2.isnull[1]

    # test (::AbstractArray) constructor
    dv = NullableArray(v)
    @test isa(dv, NullableVector{Int})

    y = NullableArray([1, 2, 3, 4, 5, 6])
    @test isa(y, NullableVector{Int})

    z = NullableArray(1.:6.)
    @test isa(z, NullableVector{Float64})

    # test (::Type{T}, dims::Dims) constructor
    u1 = NullableArray(Int, (5, ))
    u2 = NullableArray(Int, (2, 2))
    u3 = NullableArray(Int, (2, 2, 2))
    @test isa(u1, NullableVector{Int})
    @test isa(u2, NullableMatrix{Int})
    @test isa(u3, NullableArray{Int, 3})

    # test (::Type{T}, dims::Int...) constructor
    x1 = NullableArray(Int, 2)
    x2 = NullableArray(Int, 2, 2)
    x3 = NullableArray(Int, 2, 2, 2)
    @test isa(x1, NullableVector{Int})
    @test isa(x2, NullableMatrix{Int})
    @test isa(x3, NullableArray{Int, 3})

    # test NullableArray{T}(dims::Dims)
    d1, d2 = rand(1:100), rand(1:100)
    X1 = NullableArray{Int}((d1,))
    X2 = NullableArray{Int}((d1, d2))
    @test isequal(X1, NullableArray(Array{Int}((d1,)), fill(true, (d1,))))
    @test isequal(X2, NullableArray(Array{Int}((d1, d2)), fill(true, (d1, d2))))
    for i in 1:5
        m = rand(3:5)
        dims = tuple([ rand(1:5) for i in 1:m ]...)
        X3 = NullableArray{Int}(dims)
        @test isequal(X3, NullableArray(Array{Int}(dims), fill(true, dims)))
    end

    # test NullableArray{T}(dims::Int...)
    d1, d2 = rand(1:100), rand(1:100)
    X1 = NullableArray{Int}(d1)
    X2 = NullableArray{Int}(d1, d2)
    @test isequal(X1, NullableArray(Array{Int}(d1), fill(true, d1)))
    @test isequal(X2, NullableArray(Array{Int}(d1, d2), fill(true, d1, d2)))
    for i in 1:5
        m = rand(3:5)
        dims = [ rand(1:5) for i in 1:m ]
        X3 = NullableArray{Int}(dims...)
        @test isequal(X3, NullableArray(Array{Int}(dims...), fill(true, dims...)))
    end

    # test (A::AbstractArray, ::Type{T}, ::Type{U}) constructor
    z = NullableArray([1, nothing, 2, nothing, 3], Int, Void)
    @test isa(z, NullableVector{Int})
    @test z.isnull[2]
    @test z.isnull[4]

    # test (A::AbstractArray, ::Type{T}, na::Any) constructor
    Z = NullableArray([1, "na", 2, 3, 4, 5, "na"], Int, "na")
    @test isa(Z, NullableVector{Int})
    @test Z.isnull == [false, true, false, false, false, false, true]

    Y = NullableArray([1, nothing, 2, 3, 4, 5, nothing], Int, Void)
    @test isequal(Y, Z)

    # test NullableArray{T}()
    X = NullableArray{Int}()
    @test isequal(size(X), ())

    # test conversion from arrays, arrays of nullables and NullableArrays
    miss1 = [false,false,false,false]
    miss2 = [false,false,false,true]
    for (a, miss) in zip(([1, 2, 3, 4],
                          # 1:4, # Currently does not work on 0.4, cf. JuliaLang/julia#16265
                          Nullable{Int}[Nullable(1), Nullable(2), Nullable(3), Nullable()],
                          NullableArray(Nullable{Int}[Nullable(1), Nullable(2), Nullable(3), Nullable()])),
                         (miss1, miss2, miss2))
        @test isa(NullableArray(a), NullableArray{Int,1})
        @test isequal(NullableArray(a), NullableArray{Int,1}([1,2,3,4],miss))
        @test isa(NullableArray{Int64}(a), NullableArray{Int,1})
        @test isequal(NullableArray{Int64}(a), NullableArray{Int,1}([1,2,3,4],miss))
        @test isa(NullableArray{Float64}(a), NullableArray{Float64,1})
        @test isequal(NullableArray{Float64}(a), NullableArray{Float64,1}([1.0,2.0,3.0,4.0],miss))
        @test isa(NullableArray{Int64,1}(a), NullableArray{Int,1})
        @test isequal(NullableArray{Int64,1}(a), NullableArray{Int,1}([1,2,3,4],miss))
        @test isa(NullableArray{Float64,1}(a), NullableArray{Float64,1})
        @test isequal(NullableArray{Float64,1}(a), NullableArray{Float64,1}([1.0,2.0,3.0,4.0],miss))

        @test isa(convert(NullableArray, a), NullableArray{Int,1})
        @test isequal(convert(NullableArray, a), NullableArray{Int,1}([1,2,3,4],miss))
        @test isa(convert(NullableArray{Int64}, a), NullableArray{Int,1})
        @test isequal(convert(NullableArray{Int64}, a), NullableArray{Int,1}([1,2,3,4],miss))
        @test isa(convert(NullableArray{Float64}, a), NullableArray{Float64,1})
        @test isequal(convert(NullableArray{Float64}, a), NullableArray{Float64,1}([1.0,2.0,3.0,4.0],miss))
        @test isa(convert(NullableArray{Int64,1}, a), NullableArray{Int,1})
        @test isequal(convert(NullableArray{Int64,1}, a), NullableArray{Int,1}([1,2,3,4],miss))
        @test isa(convert(NullableArray{Float64,1}, a), NullableArray{Float64,1})
        @test isequal(convert(NullableArray{Float64,1}, a), NullableArray{Float64,1}([1.0,2.0,3.0,4.0],miss))
    end

    # converting a NullableArray to unqualified type NullableArray should be no-op
    m = rand(10:100)
    A = rand(m)
    M = rand(Bool, m)
    X = NullableArray(A, M)
    @test X === convert(NullableArray, X)
end


text:
using MPIMeasurements
using Base.Test
using Unitful

dR = DummyRobot()
# bR = BrukerRobot("RobotServer")
# hR = IselRobot("/dev/ttyUSB0")
moveRel(dR, dSampleRegularScanner,[10.0Unitful.mm,0.0Unitful.mm,0.0Unitful.mm])
#moveAbs(dR, dSampleRegularScanner,[0.0Unitful.mm,0.0Unitful.mm,0.0Unitful.mm])


text:
#const StatP1{T} = Union{TDist{T},Chi{T},Chisq{T},Poisson{T}}
#const StatP2 = Union{FDist,Beta,Binomial,Gamma,Normal,NoncentralT,NoncentralChisq,Logistic,Uniform}
#const StatP3 = Union{NoncentralF,GeneralizedExtremeValue}
for D in (TDist,Chi,Chisq,Poisson,FDist,Beta,Binomial,Gamma,Normal,NoncentralT,
          NoncentralChisq,Logistic,Uniform,NoncentralF,GeneralizedExtremeValue)
    fn = fieldnames(D)
    L = length(fn)

    @eval begin
        extractstat(d::$D) = map(i->getfield(d,i), $fn)
        extractstat(A::AbstractArray{$D}) = extractstat.(A)
        statview(::Type{$D}, A::AbstractArray{T,N}) where {T,N} =
            mappedarray($D, extractstat, ntuple(i->A[expand2indices(A,(i,))...], $L)...)
        @inline function Base.read(io::IO, ::Type{$(D){T}}) where {T}
            elements = Ref{NTuple{$L,T}}()
            read!(io, elements)
            $D(elements[])
        end
        @inline Base.write(io::IO, d::$D) = write(io, Ref(extractstat(d)))
    end
end


text:
module alarm_

using IUP

export
    alarm

# example html/examples/C/alarm.c
function alarm()
    IupOpen()
    r = IupAlarm("IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel")
    if (r == 1)
        IupMessage("Save file", "File saved successfully - leaving program")
    elseif (r == 2)
        IupMessage("Save file", "File not saved - leaving program anyway")
    elseif (r == 3)
        IupMessage("Save file", "Operation canceled")
    end
    IupClose()
end

end     # module


text:
cd(@__DIR__)
D = KitBase.read_dict("config.txt")
for key in keys(D)
    s = key
    @eval $s = $(D[key])
end

#--- settings ---#
Setup(
    "gas",
    "cylinder",
    "2d2f",
    "kfvs",
    "bgk",
    1, # species
    2, # order of accuracy
    "vanleer", # limiter
    "maxwell",
    0.5, # cfl
    10.0, # time
) |> show
KitBase.Scalar(1.0, 1e-3)
KitBase.Radiation(1e-2, 1.0, 0.0, 1e-3, 1000)
gas = KitBase.Gas()
show(gas)
KitBase.Mixture([0.1, 0.5], mach, prandtl, inK, 3.0, 1.0, 0.5, 0.5, 0.5) |> show
KitBase.Plasma1D(
    [0.1, 0.5],
    mach,
    prandtl,
    inK,
    3.0,
    1.0,
    0.5,
    0.5,
    0.5,
    0.01,
    0.01,
    100.0,
    1.0,
    1.0,
) |> show
KitBase.Plasma2D(
    [0.1, 0.5],
    mach,
    prandtl,
    inK,
    3.0,
    1.0,
    0.5,
    0.5,
    0.5,
    0.01,
    0.01,
    100.0,
    1.0,
    1.0,
) |> show
KitBase.DiatomicGas(
    knudsen,
    mach,
    prandtl,
    inK,
    inK,
    1.4,
    0.81,
    1.0,
    0.5,
    1e-3,
    89.1 / 273,
    18.1,
    1 / 1.55,
    0.2354,
    0.3049,
) |> show

begin
    prim = [1.0, 0.0, 1.0]
    w = KitBase.prim_conserve(prim, 1.4)
    u = Float64.(collect(umin:nu:umax)) # u should be float
    h = KitBase.maxwellian(u, prim)
    b = h .* inK ./ (2.0 * prim[end])
    x = Float64(x0) # x & dx should be of same type
    dx = (x1 - x0) / nx
end

#fw = (args...) -> [1.0, 0.0, rand()]
#KitBase.IB(fw, gas) |> show

#--- control volume ---#
KitBase.ControlVolume(w, prim, 1)
KitBase.ControlVolume(w, prim, 2)
KitBase.ControlVolume(w, prim, h, 1)
KitBase.ControlVolume(w, prim, h, 2)
KitBase.ControlVolume(w, prim, h, h, 1)
KitBase.ControlVolume(w, prim, h, h, 2)

KitBase.ControlVolume1D(w, prim) |> show
KitBase.ControlVolume1D1F(w, prim, h) |> show
KitBase.ControlVolume1D2F(w, prim, h, b) |> show
KitBase.ControlVolume1D3F(
    hcat(w, w),
    hcat(prim, prim),
    zeros(nu, nu, 2),
    zeros(nu, nu, 2),
    zeros(nu, nu, 2),
    zeros(3),
    zeros(3),
    zeros(3, 2),
) |> show
KitBase.ControlVolume1D3F(
    zeros(5, 7, 2), # indexed with [flow entry, uq, species]
    zeros(5, 7, 2),
    zeros(nu, nu, 7, 2),
    zeros(nu, nu, 7, 2),
    zeros(nu, nu, 7, 2),
    zeros(3, 7),
    zeros(3, 7),
    zeros(3, 7, 2),
) |> show
# Rykov
KitBase.ControlVolume1D3F(rand(4), rand(5), rand(nu), rand(nu), rand(nu)) |> show
KitBase.ControlVolume1D4F(
    hcat(w, w),
    hcat(prim, prim),
    hcat(h, h),
    hcat(h, h),
    hcat(h, h),
    hcat(h, h),
    zeros(3),
    zeros(3),
    zeros(3, 2),
) |> show
KitBase.ControlVolume1D4F(
    zeros(5, 7, 2), # indexed with [flow entry, uq, species]
    zeros(5, 7, 2),
    zeros(nu, 7, 2),
    zeros(nu, 7, 2),
    zeros(nu, 7, 2),
    zeros(nu, 7, 2),
    zeros(3, 7),
    zeros(3, 7),
    zeros(3, 7, 2),
) |> show
KitBase.ControlVolume2D(w, prim) |> show
KitBase.ControlVolume2D1F(w, prim, h) |> show
KitBase.ControlVolume2D2F(w, prim, h, b) |> show
KitBase.ControlVolume2D3F(w, prim, h, b, b, zeros(3), zeros(3), zeros(3, 2)) |> show
# Rykov
KitBase.ControlVolume2D3F(rand(4), rand(4), rand(8, 8), rand(8, 8), rand(8, 8)) |> show
# unstructured
KitBase.ControlVolumeUS([1, 0], x, dx, w, prim)
KitBase.ControlVolumeUS1F([1, 0], x, dx, w, prim, h)
KitBase.ControlVolumeUS2F([1, 0], x, dx, w, prim, h, b)

#--- interface ---#
KitBase.Interface1D(w) |> show
KitBase.Interface1D1F(w, h) |> show
KitBase.Interface1D2F(w, h) |> show
KitBase.Interface1D3F(w, h, zeros(3)) |> show
KitBase.Interface1D3F(zeros(5, 7, 2), zeros(21, 21, 7, 2), zeros(3, 7)) |> show
KitBase.Interface1D3F(w, h) |> show # Rykov
KitBase.Interface1D4F(w, h, zeros(3)) |> show
KitBase.Interface1D4F(zeros(5, 7, 2), zeros(21, 7, 2), zeros(3, 7)) |> show
cosa = 1 / √2
sina = 1 / √2
KitBase.Interface2D(dx, cosa, sina, w) |> show
KitBase.Interface2D1F(dx, cosa, sina, w, h) |> show
KitBase.Interface2D2F(dx, cosa, sina, w, h) |> show
KitBase.Interface2D3F(dx, cosa, sina, w, h, zeros(3)) |> show
KitBase.Interface2D3F(dx, cosa, sina, w, h, zeros(3, 7)) |> show
KitBase.Interface2D3F(dx, cosa, sina, w, h) |> show

#--- solution ---#
sol_w = rand(4, 3)
sol_prim = rand(4, 3)
sol_h = rand(6, 3)
KitBase.Solution1D(sol_w, sol_prim)
KitBase.Solution1D(sol_w, sol_prim, sol_h)
KitBase.Solution1D(sol_w, sol_prim, sol_h, sol_h)

sol_w = rand(4, 3, 2)
sol_prim = rand(4, 3, 2)
sol_h = rand(6, 3, 2)
KitBase.Solution2D(sol_w, sol_prim)
KitBase.Solution2D(sol_w, sol_prim, sol_h)
KitBase.Solution2D(sol_w, sol_prim, sol_h, sol_h)

#--- flux ---#
sol_w = rand(4, 3)
sol_h = rand(6, 3)
KitBase.Flux1D(sol_w)
KitBase.Flux1D(sol_w, sol_h)
KitBase.Flux1D(sol_w, sol_h, sol_h)

sol_w = rand(4, 3, 2)
sol_h = rand(6, 3, 2)
n = [rand(2) for i = 1:3, j = 1:2]
KitBase.Flux2D(n, sol_w)
KitBase.Flux2D(n, sol_w, sol_h)
KitBase.Flux2D(n, sol_w, sol_h, sol_h)


text:
const sync_context = gensym(:sync_context)

macro sync(ex)
    ctx = esc(sync_context)
    ex = esc(Expr(:block, __source__, ex))
    quote
        let $ctx = push_context()
            ans = $ex
            pop_context($ctx)
            ans
        end
    end
end

macro spawn(ex)
    ctx = esc(sync_context)
    ex = esc(Expr(:block, __source__, ex))
    quote
        $(Expr(:isdefined, ctx)) || unsupported_error()
        let ans, stat = start_task!($ctx)
            ans = $ex
            stop_task!($ctx, stat)
            FakeTask(ans)
        end
    end
end

abstract type AbstractContext end

# TODO: Include GC?
mutable struct TaskStat
    start::typeof(time_ns())
    stop::typeof(time_ns())

    TaskStat() = new(0, 0)
end

# TODO: Record calling function?
mutable struct SyncContext <: AbstractContext
    parent::Union{Nothing,AbstractContext}
    children::Vector{AbstractContext}
    stat::TaskStat
end

mutable struct TaskContext <: AbstractContext
    parent::SyncContext
    children::Vector{SyncContext}
    stat::TaskStat
end

function new_child!(parent::AbstractContext, ::Type{Ctx}) where {Ctx<:AbstractContext}
    child = Ctx(parent)
    push!(parent.children, child)
    return child
end

const AnyContext = Union{SyncContext,TaskContext}

SyncContext(ctx = nothing) = SyncContext(ctx, [], TaskStat())
start_stat!(ctx::SyncContext) = start_stat!(ctx.stat)
stop_stat!(ctx::SyncContext) = stop_stat!(ctx.stat)

TaskContext(ctx::SyncContext) = TaskContext(ctx, [], TaskStat())

mutable struct TaskDAGRecorder
    current::AnyContext
    root::AnyContext
end

function TaskDAGRecorder()
    ctx = SyncContext()
    ctx.stat.stop = typemax(ctx.stat.stop)
    return TaskDAGRecorder(ctx, ctx)
end

const RECORDER_KEY = :__TASK_DAG_RECORDER_KEY__

get_recorder() = task_local_storage(RECORDER_KEY)::TaskDAGRecorder

function TaskDAGRecorders.sample(f)
    recorder = TaskDAGRecorder()
    task_local_storage(RECORDER_KEY, recorder) do
        start_stat!(recorder.root)
        f()
        stop_stat!(recorder.root)
    end
    return recorder.root
end

function push_context()
    recorder = _get!(TaskDAGRecorder, task_local_storage(), RECORDER_KEY)::TaskDAGRecorder
    ctx = new_child!(recorder.current, SyncContext)
    @_debug "-> sync: $(objectid(ctx))"
    recorder.current = ctx
    start_stat!(ctx)
    return ctx
end

function pop_context(ctx::SyncContext)
    stop_stat!(ctx)
    @_debug "<- sync: $(objectid(ctx))"
    recorder = get_recorder()
    @assert recorder.current === ctx
    recorder.current = ctx.parent
    return
end

function start_stat!(stat::TaskStat)
    stat.start = time_ns()
    return stat
end

function stop_stat!(stat::TaskStat)
    stat.stop = time_ns()
    return stat
end

function start_task!(ctx::SyncContext)
    recorder = get_recorder()
    if recorder.current !== ctx
        @_debug "recorder.current: $(objectid(recorder.current)) != ctx: $(objectid(ctx))"
    end
    @assert recorder.current === ctx
    task = new_child!(recorder.current, TaskContext)
    recorder.current = task
    @_debug "-> spawn: $(objectid(task)) in $(objectid(ctx))"
    start_stat!(task.stat)
    return task
end

function stop_task!(ctx::SyncContext, task::TaskContext)
    recorder = get_recorder()
    if recorder.current !== task
        @_debug "recorder.current: $(objectid(recorder.current)) != task: $(objectid(task))"
    end
    @assert recorder.current === task
    @assert task.parent === ctx
    recorder.current = ctx
    stop_stat!(task.stat)
    @_debug "<- spawn: $(objectid(task)) in $(objectid(ctx))"
end

struct FakeTask
    result::Any
end

Base.fetch(t::FakeTask) = t.result
Base.wait(::FakeTask) = nothing

function unsupported_error()
    error("`@spawn` without `@sync` is not supported")
end

"""
    TaskDAGRecorders.sample(f) -> context
    TaskDAGRecorders.sample(f, n::Integer) -> contexts::Vector

Log tasks (span and sync operations) while executing `f`. The code executed in
`f` must be instrumented by `using TaskDAGRecorders: @sync, Threads`.

The unary method runs `f` once and return a single `context` that records the
task operations.

The binary method runs `f` repeatedly `n` times and return a vector of contexts
that record the task operations.

Use `TaskDAGAnalyzers.dag` to convert this into a DAG representation.
"""
TaskDAGRecorders.sample

function TaskDAGRecorders.sample(f, n::Integer)
    samples = Vector{SyncContext}(undef, n)
    for i in 1:n
        samples[i] = TaskDAGRecorders.sample(f)
    end
    return samples
end

function get_sync_context(recorder = get_recorder())
    ctx = recorder.root
    if ctx isa SyncContext
        if length(ctx) == 0
            return ctx
        elseif length(ctx.children) == 1
            child, = ctx.children
            if child isa SyncContext
                return child
            else
                return ctx
            end
        end
        stat = TaskStat()
        stat.start = ctx.children[1].start
        stat.stop = ctx.children[end].stop
        return SyncContext(nothing, ctx.children, stat)
    elseif ctx isa TaskContext
        error("unexpected TaskContext")
    end
    error("unreachable")
end


text:
using ArviZ
using Test

@testset "ArviZ" begin
    include("helpers.jl")
    include("test_rcparams.jl")
    include("test_utils.jl")
    include("test_backend.jl")
    include("test_dataset.jl")
    include("test_data.jl")
    include("test_diagnostics.jl")
    include("test_stats.jl")
    include("test_plots.jl")
    include("test_namedtuple.jl")
    include("test_samplechains.jl")
    include("test_mcmcchains.jl")
end


text:
identity_fun(d::Circle)=Fun([d.center,0.,d.radius],Laurent(d))

Space(d::PeriodicDomain)=Fourier(d)
Space(d::Circle)=Laurent(d)

## Evaluation

Evaluation(d::PeriodicDomain,x::Number,n...) = Evaluation(Laurent(d),complex(x),n...)

## Definite Integral

DefiniteIntegral(d::PeriodicDomain) = DefiniteIntegral(Laurent(d))
DefiniteLineIntegral(d::PeriodicDomain) = DefiniteLineIntegral(Laurent(d))

## Toeplitz


text:
# LU decomposition of a band-diagonal matrix (ala Numerical Recipes)
#
function bandec(a::Array{Float64,2},n::Int64,m1::Int64,m2::Int64,al::Array{Float64,2},indx::Vector{Int64})
#      INTEGER m1,m2,mp,mpl,n,np,indx(n)
#      REAL d,a(np,mp),al(np,mpl),TINY
mm=m1+m2+1
@assert(size(a)  == (n,mm))
@assert(size(al) == (n,m1))
@assert(length(indx) == n)
TINY=1.e-20
#      INTEGER i,j,k,l,mm
#      REAL dum
l=m1
dum = 0.0
for i=1:m1
  for j=m1+2-i:mm
    a[i,j-l]=a[i,j]
  end
  l -= 1
  for j=mm-l:mm
    a[i,j]=0.0
  end
end
d=1.0
l=m1
for k=1:n
  dum=a[k,1]
  i=k
  if (l < n)
    l += 1
  end
  for j=k+1:l
    if (abs(a[j,1]) > abs(dum))
      dum=a[j,1]
      i=j
    end
  end
  indx[k]=i
  if (dum == 0.0)
    a[k,1]=TINY
  end
  if (i != k)
    d = -d
    for j=1:mm
      dum=a[k,j]
      a[k,j]=a[i,j]
      a[i,j]=dum
    end
  end
  for i=k+1:l
    dum=a[i,1]/a[k,1]
    al[k,i-k]=dum
    for j=2:mm
      a[i,j-1] = a[i,j] - dum*a[k,j]
    end
    a[i,mm]=0.
  end
end
return d
end

#  (C) Copr. 1986-92 Numerical Recipes Software

function bandec(a::Array{Complex{Float64},2},n::Int64,m1::Int64,m2::Int64,al::Array{Complex{Float64},2},indx::Vector{Int64})
#      INTEGER m1,m2,mp,mpl,n,np,indx(n)
#      REAL d,a(np,mp),al(np,mpl),TINY
mm=m1+m2+1
@assert(size(a)  == (n,mm))
@assert(size(al) == (n,m1))
@assert(length(indx) == n)
TINY=complex(1.e-20,0.0)
#      INTEGER i,j,k,l,mm
#      REAL dum
l=m1
dum = complex(0.0,0.0)
for i=1:m1
  for j=m1+2-i:mm
    a[i,j-l]=a[i,j]
  end
  l -= 1
  for j=mm-l:mm
    a[i,j]=complex(0.0,0.0)
  end
end
d=1.0
l=m1
for k=1:n
  dum=a[k,1]
  i=k
  if (l < n)
    l += 1
  end
  for j=k+1:l
    if (abs(a[j,1]) > abs(dum))
      dum=a[j,1]
      i=j
    end
  end
  indx[k]=i
  if (dum == 0.0)
    a[k,1]=TINY
  end
  if (i != k)
    d = -d
    for j=1:mm
      dum=a[k,j]
      a[k,j]=a[i,j]
      a[i,j]=dum
    end
  end
  for i=k+1:l
    dum=a[i,1]/a[k,1]
    al[k,i-k]=dum
    for j=2:mm
      a[i,j-1] = a[i,j] - dum*a[k,j]
    end
    a[i,mm]=0.
  end
end
return d
end

#  (C) Copr. 1986-92 Numerical Recipes Software


text:
@testset "statistics.jl" begin
    println("             > statistics.jl")
    @testset "MAP, marginal = true" begin
        model = BinomialModel(
                    [1, 2, 2, 2, 4, 4],
                    [0.1, 0.3, 0.4, 0.5, 0.5, 0.5],
                    [0.3, 0.3, 0.7, 0.1, 0.2, 0.3],
                    [0.1, 0.2, 0.3, 0.4, 0.5, 0.6],
                    [0.1, 0.1, 0.2, 0.3, 0.5, 0.5]
        )

        map = MAP(model, marginal = true)

        @test map.N == 2
        @test map.p == 0.5
        @test map.q == 0.3
        @test map.σ == 0.1
        @test map.τ == 0.1
    end
    @testset "MAP" begin
        model = BinomialModel(
                    [1, 2, 2, 2, 4, 4],
                    [0.1, 0.3, 0.3, 0.3, 0.5, 0.5],
                    [0.3, 0.2, 0.2, 0.2, 0.1, 0.3],
                    [0.1, 0.5, 0.5, 0.5, 0.5, 0.6],
                    [0.1, 0.8, 0.8, 0.8, 0.5, 0.5]
        )

        map = MAP(model)

        @test map.N == 2
        @test map.p == 0.3
        @test map.q == 0.2
        @test map.σ == 0.5
        @test map.τ == 0.8
    end
end


text:
module VerticesTests

using FixedSizeArrays, Contour, Base.Test

# Setup test axes that will be shared among the tests

# Shift the axes so that they do not line up with
# integer values
Δ = 0.01
X = collect(0:Δ:4) + π
Y = collect(0:Δ:3) + φ

# TEST CASE 1
#
# f(x,y) = x^2 + y^2
#
Z = [(x^2 + y^2)::Float64 for x in X, y in Y]
h = rand()*(maximum(Z) - minimum(Z)) + minimum(Z)

contourlevels = Contour.contour(X,Y,Z, h)
for line in contourlevels.lines
    # Contour vertices lie on a circle around the origin
    for v in line.vertices
        @test_approx_eq_eps v[1]^2 + v[2]^2 h 0.1Δ
    end

    # coordinates() returns the correct values
    xs,ys = coordinates(line)
    xs .== [v[1] for v in line.vertices]
    ys .== [v[2] for v in line.vertices]
end

# TEST CASE 1.5
#
# Same as test case 1, but with a shifted center
#
h = 1
x0,y0 = (.5,-1.5)
Z = Float64[(x-x0)^2+(y-y0)^2 for x in X, y in Y]

contourlevels = Contour.contour(X, Y, Z, h)
for line in contourlevels.lines
    for v in line.vertices
        @test_approx_eq_eps ((v[1]-x0)^2 + (v[2]-y0)^2) h 0.01Δ
    end
end

# TEST CASE 2
#
# Check that ambigious cells (5, 10) are handled correctly
# Case 5: z_center > h
X = [1.0,2.0]
Y = [2.0,1.0]

Z = float([1 0;
           0 1])
h = 0.1

lines = Contour.contour(X, Y, Z, h).lines
@test length(lines) == 2

for line in lines
    @test length(line.vertices) == 2
    Δ = line.vertices[2] - line.vertices[1]
    @test_approx_eq Δ[2]/Δ[1] -1.0
end

# Case 5: z_center < h
Z = float([1 0;
           0 1])
h = 0.9

lines = Contour.contour(X, Y, Z, h).lines

@test length(lines) == 2

for line in lines
    @test length(line.vertices) == 2
    Δ = line.vertices[2] - line.vertices[1]
    @test_approx_eq Δ[2]/Δ[1] 1.0
end

# Case 10: z_center > h
Z = float([0 1;
           1 0])
h = 0.1

lines = Contour.contour(X, Y, Z, h).lines
@test length(lines) == 2

for line in lines
    @test length(line.vertices) == 2
    Δ = line.vertices[2] - line.vertices[1]
    @test_approx_eq Δ[2]/Δ[1] 1.0
end

# Case 10: z_center < h

Z = float([0 1;
           1 0])
h = 0.9

lines = Contour.contour(X, Y, Z, h).lines
@test length(lines) == 2

for line in lines
    @test length(line.vertices) == 2
    Δ = line.vertices[2] - line.vertices[1]
    @test_approx_eq Δ[2]/Δ[1] -1.0
end

# Test Known Bugs

# Issue #12
x = float(collect(1:3));
y = copy(x);
z = eye(3,3);
contours(x,y,z)

# Test handling of saddle points
#
# f(x,y) = x^2 - y^2
#
Δ = 0.01
X = collect(-3:Δ:3)
Y = collect(-3:Δ:3)

Z = [(x^2 - y^2)::Float64 for x in X, y in Y]
h = rand()*(maximum(Z) - minimum(Z)) + minimum(Z)

contourlevels = Contour.contour(X,Y,Z, h)
for line in contourlevels.lines
    # Contour vertices lie on a circle around the origin
    for v in line.vertices
        @test_approx_eq_eps v[1]^2 - v[2]^2 h 0.1Δ
    end

    # coordinates() returns the correct values
    xs,ys = coordinates(line)
    xs .== [v[1] for v in line.vertices]
    ys .== [v[2] for v in line.vertices]
end

# Test that closed contours are identified correctly
# when ambiguous cells are involved

Z = float([1 1 1 1 1 1
           1 0 0 1 1 1
           1 0 0 1 1 1
           1 1 1 0 0 1
           1 1 1 0 0 1
           1 1 1 1 1 1])

X = Y = collect(0:0.2:1)
h = 0.75
contourlevels = Contour.contour(X,Y,Z,h)

# There should be only one closed contour
@test length(contourlevels.lines) == 1

# Test contour location on a realistic dataset
include("testdata.jl")
Contour.contours(x,y,z)

end


text:
# test module wrapping

addprocs(1)

@everywhere using Base.Test

@everywhere module First

using Compat

export solve, InferenceType, Container

@compat abstract type InferenceType end

type Container
  col::Dict{Symbol, Function}
  Container(::Void) = new()
  Container(;col=Dict{Symbol, Function}()) = new(col)
end

function registerCallback!(col::Container, fnc::Function)
  # get module
  # Symbol(string(m))
  m = Symbol(typeof(fnc).name.module)
  col.col[m] = fnc
end

function solve(ctl::Container, val::InferenceType) # m::Symbol,
  m = Symbol(typeof(val).name.module)
  if false
    # doesnt work
    evalPotential(val)
  else
    evalPotential = ctl.col[m]
    evalPotential(val)
  end
end

end

@everywhere module Second
importall First
export SecondType, SecondAgain, evalPotential, solve, registerCallback!, Container

type SecondType <: First.InferenceType
  x::Int
end
type SecondAgain <: First.InferenceType
  x::Int
end

function evalPotential(x::SecondType)
  println("evalPotential sees $(x)")
  return x.x
end

function evalPotential(x::SecondAgain)
  println("evalPotential also sees $(x)")
  return x.x
end

end

# get module
# typeof(f).name.mt.name

# Okay lets see
using Second
@everywhere using Second

Col = First.Container()

# running on first process only
First.registerCallback!(Col, Second.evalPotential)

CCol = deepcopy(Col)

stA = 1.0
saA = 3.0

st = Second.SecondType(stA)
sa = Second.SecondAgain(saA)

# Symbol(typeof(st).name.module)
@test First.solve(CCol, st) == stA
@test First.solve(CCol, sa) == saA

@elapsed evalPotential(st)
t1 = @elapsed evalPotential(st)
t2 = @elapsed solve(Col, sa)

println("Check the speed is reasonable")
@test t2 < 15.0*t1 # should actually be about equal, slack for threading uncertainty

# expand tests to include multiprocessor
# println("Tesing call of function on separate process...")
# fr = remotecall(evalPotential,procs()[2], st)
# @test fetch(fr) == stA
#
# fr = remotecall(solve,procs()[2], CCol,sa)
# @test fetch(fr) == saA
#
#
#
# println("Stopping all but first process...")
# rmprocs(procs()[2:end])
# @show procs()

#


text:
#!/usr/bin/env julia

using SimradEK60TestData
using Test

@test isfile(EK60_SAMPLE)
@test isfile(ECS_SAMPLE)
@test isfile(joinpath(EK60_DATA, "JR230.ecs"))


text:
module TestTools

end#module


text:
using SVDD
using JuMP, Ipopt
using StatsBase, Distributions
using MLKernels, MLLabelUtils
using Test
using LinearAlgebra, Random

TEST_SOLVER =  with_optimizer(Ipopt.Optimizer, print_level=0)

include("test_utils.jl")

@testset "SVDD" begin
    include("svdd_util_test.jl")

    include("classifiers/classifier_test.jl")
    include("classifiers/classifier_ssad_test.jl")
    include("classifiers/classifier_svdd_test.jl")
    include("classifiers/classifier_svdd_neg_test.jl")
    include("classifiers/classifier_svdd_vanilla_test.jl")

    include("init_strategies/init_strategies_test.jl")
end