Added first few tests and mt19937
This commit is contained in:
commit
85196b5d84
BIN
rng/.DS_Store
vendored
Normal file
BIN
rng/.DS_Store
vendored
Normal file
Binary file not shown.
284
rng/rng.xcodeproj/project.pbxproj
Normal file
284
rng/rng.xcodeproj/project.pbxproj
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 77;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
4DD424762E01CCB60012A242 /* CopyFiles */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = /usr/share/man/man1/;
|
||||||
|
dstSubfolderSpec = 0;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 1;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
4DD424782E01CCB60012A242 /* rng */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = rng; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||||
|
4DD4247A2E01CCB60012A242 /* rng */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
path = rng;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXFileSystemSynchronizedRootGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
4DD424752E01CCB60012A242 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
4DD4246F2E01CCB60012A242 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
4DD4247A2E01CCB60012A242 /* rng */,
|
||||||
|
4DD424792E01CCB60012A242 /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
4DD424792E01CCB60012A242 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
4DD424782E01CCB60012A242 /* rng */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
4DD424772E01CCB60012A242 /* rng */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 4DD4247F2E01CCB60012A242 /* Build configuration list for PBXNativeTarget "rng" */;
|
||||||
|
buildPhases = (
|
||||||
|
4DD424742E01CCB60012A242 /* Sources */,
|
||||||
|
4DD424752E01CCB60012A242 /* Frameworks */,
|
||||||
|
4DD424762E01CCB60012A242 /* CopyFiles */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
fileSystemSynchronizedGroups = (
|
||||||
|
4DD4247A2E01CCB60012A242 /* rng */,
|
||||||
|
);
|
||||||
|
name = rng;
|
||||||
|
packageProductDependencies = (
|
||||||
|
);
|
||||||
|
productName = rng;
|
||||||
|
productReference = 4DD424782E01CCB60012A242 /* rng */;
|
||||||
|
productType = "com.apple.product-type.tool";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
4DD424702E01CCB60012A242 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = 1;
|
||||||
|
LastUpgradeCheck = 1600;
|
||||||
|
TargetAttributes = {
|
||||||
|
4DD424772E01CCB60012A242 = {
|
||||||
|
CreatedOnToolsVersion = 16.0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 4DD424732E01CCB60012A242 /* Build configuration list for PBXProject "rng" */;
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 4DD4246F2E01CCB60012A242;
|
||||||
|
minimizedProjectReferenceProxies = 1;
|
||||||
|
preferredProjectObjectVersion = 77;
|
||||||
|
productRefGroup = 4DD424792E01CCB60012A242 /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
4DD424772E01CCB60012A242 /* rng */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
4DD424742E01CCB60012A242 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
4DD4247D2E01CCB60012A242 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
4DD4247E2E01CCB60012A242 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 15.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
4DD424802E01CCB60012A242 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
4DD424812E01CCB60012A242 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
4DD424732E01CCB60012A242 /* Build configuration list for PBXProject "rng" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
4DD4247D2E01CCB60012A242 /* Debug */,
|
||||||
|
4DD4247E2E01CCB60012A242 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
4DD4247F2E01CCB60012A242 /* Build configuration list for PBXNativeTarget "rng" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
4DD424802E01CCB60012A242 /* Debug */,
|
||||||
|
4DD424812E01CCB60012A242 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 4DD424702E01CCB60012A242 /* Project object */;
|
||||||
|
}
|
7
rng/rng.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
rng/rng.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
BIN
rng/rng.xcodeproj/project.xcworkspace/xcuserdata/asher.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
BIN
rng/rng.xcodeproj/project.xcworkspace/xcuserdata/asher.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
Binary file not shown.
80
rng/rng.xcodeproj/xcshareddata/xcschemes/rng.xcscheme
Normal file
80
rng/rng.xcodeproj/xcshareddata/xcschemes/rng.xcscheme
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1600"
|
||||||
|
version = "1.7">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES"
|
||||||
|
buildArchitectures = "Automatic">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "4DD424772E01CCB60012A242"
|
||||||
|
BuildableName = "rng"
|
||||||
|
BlueprintName = "rng"
|
||||||
|
ReferencedContainer = "container:rng.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
shouldAutocreateTestPlan = "YES">
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "YES"
|
||||||
|
customWorkingDirectory = "/Users/asher/Downloads/rng/rng/rng"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES"
|
||||||
|
viewDebuggingEnabled = "No">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "4DD424772E01CCB60012A242"
|
||||||
|
BuildableName = "rng"
|
||||||
|
BlueprintName = "rng"
|
||||||
|
ReferencedContainer = "container:rng.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "4DD424772E01CCB60012A242"
|
||||||
|
BuildableName = "rng"
|
||||||
|
BlueprintName = "rng"
|
||||||
|
ReferencedContainer = "container:rng.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>SchemeUserState</key>
|
||||||
|
<dict>
|
||||||
|
<key>rng.xcscheme_^#shared#^_</key>
|
||||||
|
<dict>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
<dict>
|
||||||
|
<key>4DD424772E01CCB60012A242</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
BIN
rng/rng/.DS_Store
vendored
Normal file
BIN
rng/rng/.DS_Store
vendored
Normal file
Binary file not shown.
63
rng/rng/.vscode/settings.json
vendored
Normal file
63
rng/rng/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"*.ts": "typescriptreact",
|
||||||
|
"array": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"__bit_reference": "cpp",
|
||||||
|
"__hash_table": "cpp",
|
||||||
|
"__locale": "cpp",
|
||||||
|
"__node_handle": "cpp",
|
||||||
|
"__split_buffer": "cpp",
|
||||||
|
"__threading_support": "cpp",
|
||||||
|
"__verbose_abort": "cpp",
|
||||||
|
"bitset": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"complex": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"execution": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"ios": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"locale": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"print": "cpp",
|
||||||
|
"queue": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stack": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"variant": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"__tree": "cpp",
|
||||||
|
"csignal": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"set": "cpp",
|
||||||
|
"unordered_set": "cpp"
|
||||||
|
}
|
||||||
|
}
|
BIN
rng/rng/a.out
Executable file
BIN
rng/rng/a.out
Executable file
Binary file not shown.
7134
rng/rng/code_tests/doctest.h
Normal file
7134
rng/rng/code_tests/doctest.h
Normal file
File diff suppressed because it is too large
Load Diff
201
rng/rng/code_tests/test.cpp
Normal file
201
rng/rng/code_tests/test.cpp
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||||
|
#include "./doctest.h"
|
||||||
|
|
||||||
|
#include "../math/incomplete_gamma.cpp"
|
||||||
|
|
||||||
|
TEST_CASE("igam function"){
|
||||||
|
|
||||||
|
// generate igam tests with this python script
|
||||||
|
|
||||||
|
// import scipy
|
||||||
|
// for i in range(1,10):
|
||||||
|
// for ii in range(20):
|
||||||
|
// print(f"igamtest({i/2}, {ii/2}, {scipy.special.gammainc(i/2,ii/2)});")
|
||||||
|
|
||||||
|
|
||||||
|
auto igamtest = [](double a, double x, double req) {
|
||||||
|
REQUIRE(igam(a,x)== doctest::Approx(req).epsilon(0.00000000000001));
|
||||||
|
};
|
||||||
|
{
|
||||||
|
igamtest(0.5, 0.0, 0.0);
|
||||||
|
igamtest(0.5, 0.5, 0.6826894921370859);
|
||||||
|
igamtest(0.5, 1.0, 0.8427007929497151);
|
||||||
|
igamtest(0.5, 1.5, 0.9167354833364495);
|
||||||
|
igamtest(0.5, 2.0, 0.9544997361036416);
|
||||||
|
igamtest(0.5, 2.5, 0.9746526813225318);
|
||||||
|
igamtest(0.5, 3.0, 0.9856941215645704);
|
||||||
|
igamtest(0.5, 3.5, 0.9918490284064974);
|
||||||
|
igamtest(0.5, 4.0, 0.9953222650189527);
|
||||||
|
igamtest(0.5, 4.5, 0.9973002039367398);
|
||||||
|
igamtest(0.5, 5.0, 0.9984345977419975);
|
||||||
|
igamtest(0.5, 5.5, 0.9990888811228463);
|
||||||
|
igamtest(0.5, 6.0, 0.9994679944948608);
|
||||||
|
igamtest(0.5, 6.5, 0.9996885090232326);
|
||||||
|
igamtest(0.5, 7.0, 0.9998171893670181);
|
||||||
|
igamtest(0.5, 7.5, 0.9998924888232705);
|
||||||
|
igamtest(0.5, 8.0, 0.9999366575163338);
|
||||||
|
igamtest(0.5, 8.5, 0.9999626201815983);
|
||||||
|
igamtest(0.5, 9.0, 0.9999779095030014);
|
||||||
|
igamtest(0.5, 9.5, 0.9999869281546332);
|
||||||
|
igamtest(1.0, 0.0, 0.0);
|
||||||
|
igamtest(1.0, 0.5, 0.3934693402873665);
|
||||||
|
igamtest(1.0, 1.0, 0.6321205588285577);
|
||||||
|
igamtest(1.0, 1.5, 0.7768698398515702);
|
||||||
|
igamtest(1.0, 2.0, 0.8646647167633873);
|
||||||
|
igamtest(1.0, 2.5, 0.9179150013761012);
|
||||||
|
igamtest(1.0, 3.0, 0.950212931632136);
|
||||||
|
igamtest(1.0, 3.5, 0.9698026165776815);
|
||||||
|
igamtest(1.0, 4.0, 0.9816843611112658);
|
||||||
|
igamtest(1.0, 4.5, 0.9888910034617577);
|
||||||
|
igamtest(1.0, 5.0, 0.9932620530009145);
|
||||||
|
igamtest(1.0, 5.5, 0.995913228561536);
|
||||||
|
igamtest(1.0, 6.0, 0.9975212478233336);
|
||||||
|
igamtest(1.0, 6.5, 0.9984965608070224);
|
||||||
|
igamtest(1.0, 7.0, 0.9990881180344455);
|
||||||
|
igamtest(1.0, 7.5, 0.9994469156298522);
|
||||||
|
igamtest(1.0, 8.0, 0.9996645373720975);
|
||||||
|
igamtest(1.0, 8.5, 0.9997965316309894);
|
||||||
|
igamtest(1.0, 9.0, 0.9998765901959134);
|
||||||
|
igamtest(1.0, 9.5, 0.9999251481701124);
|
||||||
|
igamtest(1.5, 0.0, 0.0);
|
||||||
|
igamtest(1.5, 0.5, 0.19874804309879915);
|
||||||
|
igamtest(1.5, 1.0, 0.42759329552912023);
|
||||||
|
igamtest(1.5, 1.5, 0.6083748237289109);
|
||||||
|
igamtest(1.5, 2.0, 0.7385358700508897);
|
||||||
|
igamtest(1.5, 2.5, 0.8282028557032668);
|
||||||
|
igamtest(1.5, 3.0, 0.8883897749052875);
|
||||||
|
igamtest(1.5, 3.5, 0.9281022275035349);
|
||||||
|
igamtest(1.5, 4.0, 0.9539882943107686);
|
||||||
|
igamtest(1.5, 4.5, 0.9707091134651118);
|
||||||
|
igamtest(1.5, 5.0, 0.9814338645369568);
|
||||||
|
igamtest(1.5, 5.5, 0.9882741244215786);
|
||||||
|
igamtest(1.5, 6.0, 0.9926168394946402);
|
||||||
|
igamtest(1.5, 6.5, 0.9953633945619583);
|
||||||
|
igamtest(1.5, 7.0, 0.9970948472257326);
|
||||||
|
igamtest(1.5, 7.5, 0.9981833510334277);
|
||||||
|
igamtest(1.5, 8.0, 0.9988660157102147);
|
||||||
|
igamtest(1.5, 8.5, 0.999293257607663);
|
||||||
|
igamtest(1.5, 9.0, 0.9995601503471612);
|
||||||
|
igamtest(1.5, 9.5, 0.9997266011125092);
|
||||||
|
igamtest(2.0, 0.0, 0.0);
|
||||||
|
igamtest(2.0, 0.5, 0.09020401043104986);
|
||||||
|
igamtest(2.0, 1.0, 0.2642411176571153);
|
||||||
|
igamtest(2.0, 1.5, 0.4421745996289252);
|
||||||
|
igamtest(2.0, 2.0, 0.5939941502901616);
|
||||||
|
igamtest(2.0, 2.5, 0.7127025048163542);
|
||||||
|
igamtest(2.0, 3.0, 0.8008517265285442);
|
||||||
|
igamtest(2.0, 3.5, 0.8641117745995668);
|
||||||
|
igamtest(2.0, 4.0, 0.9084218055563291);
|
||||||
|
igamtest(2.0, 4.5, 0.9389005190396673);
|
||||||
|
igamtest(2.0, 5.0, 0.9595723180054873);
|
||||||
|
igamtest(2.0, 5.5, 0.9734359856499836);
|
||||||
|
igamtest(2.0, 6.0, 0.9826487347633355);
|
||||||
|
igamtest(2.0, 6.5, 0.9887242060526682);
|
||||||
|
igamtest(2.0, 7.0, 0.9927049442755639);
|
||||||
|
igamtest(2.0, 7.5, 0.9952987828537434);
|
||||||
|
igamtest(2.0, 8.0, 0.9969808363488774);
|
||||||
|
igamtest(2.0, 8.5, 0.9980670504943989);
|
||||||
|
igamtest(2.0, 9.0, 0.9987659019591332);
|
||||||
|
igamtest(2.0, 9.5, 0.9992140557861792);
|
||||||
|
igamtest(2.5, 0.0, 0.0);
|
||||||
|
igamtest(2.5, 0.5, 0.03743422675270362);
|
||||||
|
igamtest(2.5, 1.0, 0.15085496391539038);
|
||||||
|
igamtest(2.5, 1.5, 0.3000141641213724);
|
||||||
|
igamtest(2.5, 2.0, 0.4505840486472197);
|
||||||
|
igamtest(2.5, 2.5, 0.5841198130044919);
|
||||||
|
igamtest(2.5, 3.0, 0.6937810815867218);
|
||||||
|
igamtest(2.5, 3.5, 0.7793596920632895);
|
||||||
|
igamtest(2.5, 4.0, 0.8437643724222776);
|
||||||
|
igamtest(2.5, 4.5, 0.8909358420502275);
|
||||||
|
igamtest(2.5, 5.0, 0.9247647538534879);
|
||||||
|
igamtest(2.5, 5.5, 0.9486200165169305);
|
||||||
|
igamtest(2.5, 6.0, 0.9652122194937581);
|
||||||
|
igamtest(2.5, 6.5, 0.9766212318964361);
|
||||||
|
igamtest(2.5, 7.0, 0.9843905838997331);
|
||||||
|
igamtest(2.5, 7.5, 0.9896376620842136);
|
||||||
|
igamtest(2.5, 8.0, 0.9931559260775795);
|
||||||
|
igamtest(2.5, 8.5, 0.9955002030220295);
|
||||||
|
igamtest(2.5, 9.0, 0.9970535954121197);
|
||||||
|
igamtest(2.5, 9.5, 0.998077863179057);
|
||||||
|
igamtest(3.0, 0.0, 0.0);
|
||||||
|
igamtest(3.0, 0.5, 0.01438767796697068);
|
||||||
|
igamtest(3.0, 1.0, 0.08030139707139418);
|
||||||
|
igamtest(3.0, 1.5, 0.19115316946194183);
|
||||||
|
igamtest(3.0, 2.0, 0.3233235838169364);
|
||||||
|
igamtest(3.0, 2.5, 0.4561868841166703);
|
||||||
|
igamtest(3.0, 3.0, 0.5768099188731565);
|
||||||
|
igamtest(3.0, 3.5, 0.6791528011378659);
|
||||||
|
igamtest(3.0, 4.0, 0.7618966944464557);
|
||||||
|
igamtest(3.0, 4.5, 0.8264219290899639);
|
||||||
|
igamtest(3.0, 5.0, 0.8753479805169189);
|
||||||
|
igamtest(3.0, 5.5, 0.9116235676432145);
|
||||||
|
igamtest(3.0, 6.0, 0.938031195583341);
|
||||||
|
igamtest(3.0, 6.5, 0.9569640531010171);
|
||||||
|
igamtest(3.0, 7.0, 0.9703638361194782);
|
||||||
|
igamtest(3.0, 7.5, 0.9797432849433356);
|
||||||
|
igamtest(3.0, 8.0, 0.986246032255997);
|
||||||
|
igamtest(3.0, 8.5, 0.9907167556638894);
|
||||||
|
igamtest(3.0, 9.0, 0.9937678048936227);
|
||||||
|
igamtest(3.0, 9.5, 0.9958363669624967);
|
||||||
|
igamtest(3.5, 0.0, 0.0);
|
||||||
|
igamtest(3.5, 0.5, 0.0051714634834845175);
|
||||||
|
igamtest(3.5, 1.0, 0.04015963126989843);
|
||||||
|
igamtest(3.5, 1.5, 0.11499776835684938);
|
||||||
|
igamtest(3.5, 2.0, 0.22022259152428406);
|
||||||
|
igamtest(3.5, 2.5, 0.34003677030571744);
|
||||||
|
igamtest(3.5, 3.0, 0.4602506496044427);
|
||||||
|
igamtest(3.5, 3.5, 0.5711201424469452);
|
||||||
|
igamtest(3.5, 4.0, 0.6674060974006921);
|
||||||
|
igamtest(3.5, 4.5, 0.7473439535034361);
|
||||||
|
igamtest(3.5, 5.0, 0.81142653248655);
|
||||||
|
igamtest(3.5, 5.5, 0.8613809791267045);
|
||||||
|
igamtest(3.5, 6.0, 0.8994411314916412);
|
||||||
|
igamtest(3.5, 6.5, 0.9278916089660787);
|
||||||
|
igamtest(3.5, 7.0, 0.9488186465869346);
|
||||||
|
igamtest(3.5, 7.5, 0.9640005952365712);
|
||||||
|
igamtest(3.5, 8.0, 0.9748836392531472);
|
||||||
|
igamtest(3.5, 8.5, 0.9826038174308754);
|
||||||
|
igamtest(3.5, 9.0, 0.9880299976459704);
|
||||||
|
igamtest(3.5, 9.5, 0.9918126590319385);
|
||||||
|
igamtest(4.0, 0.0, 0.0);
|
||||||
|
igamtest(4.0, 0.5, 0.001751622556290824);
|
||||||
|
igamtest(4.0, 1.0, 0.01898815687615381);
|
||||||
|
igamtest(4.0, 1.5, 0.06564245437845008);
|
||||||
|
igamtest(4.0, 2.0, 0.14287653950145296);
|
||||||
|
igamtest(4.0, 2.5, 0.2424238668669339);
|
||||||
|
igamtest(4.0, 3.0, 0.35276811121776874);
|
||||||
|
igamtest(4.0, 3.5, 0.463367332099215);
|
||||||
|
igamtest(4.0, 4.0, 0.566529879633291);
|
||||||
|
igamtest(4.0, 4.5, 0.657704044165409);
|
||||||
|
igamtest(4.0, 5.0, 0.7349740847026385);
|
||||||
|
igamtest(4.0, 5.5, 0.7983008012974713);
|
||||||
|
igamtest(4.0, 6.0, 0.8487961172233521);
|
||||||
|
igamtest(4.0, 6.5, 0.8881503883724394);
|
||||||
|
igamtest(4.0, 7.0, 0.9182345837552784);
|
||||||
|
igamtest(4.0, 7.5, 0.9408545401673161);
|
||||||
|
igamtest(4.0, 8.0, 0.957619888008316);
|
||||||
|
igamtest(4.0, 8.5, 0.9698909203107791);
|
||||||
|
igamtest(4.0, 9.0, 0.9787735136970911);
|
||||||
|
igamtest(4.0, 9.5, 0.9851403523541687);
|
||||||
|
igamtest(4.5, 0.0, 0.0);
|
||||||
|
igamtest(4.5, 0.5, 0.0005624973021675015);
|
||||||
|
igamtest(4.5, 1.0, 0.008532393371186466);
|
||||||
|
igamtest(4.5, 1.5, 0.035705027314910875);
|
||||||
|
igamtest(4.5, 2.0, 0.08858747316832083);
|
||||||
|
igamtest(4.5, 2.5, 0.16569173980659246);
|
||||||
|
igamtest(4.5, 3.0, 0.2600817079053462);
|
||||||
|
igamtest(4.5, 3.5, 0.36288059283060153);
|
||||||
|
igamtest(4.5, 4.0, 0.4658537830903085);
|
||||||
|
igamtest(4.5, 4.5, 0.5627258110861331);
|
||||||
|
igamtest(4.5, 5.0, 0.6495147876766386);
|
||||||
|
igamtest(4.5, 5.5, 0.724291063227778);
|
||||||
|
igamtest(4.5, 6.0, 0.7866906949165835);
|
||||||
|
igamtest(4.5, 6.5, 0.8373937378097005);
|
||||||
|
igamtest(4.5, 7.0, 0.8776747719613376);
|
||||||
|
igamtest(4.5, 7.5, 0.9090640234201949);
|
||||||
|
igamtest(4.5, 8.0, 0.9331184122258733);
|
||||||
|
igamtest(4.5, 8.5, 0.9512840238523587);
|
||||||
|
igamtest(4.5, 9.0, 0.9648264605330151);
|
||||||
|
igamtest(4.5, 9.5, 0.974807104918331);
|
||||||
|
}
|
||||||
|
}
|
3
rng/rng/codetest.sh
Executable file
3
rng/rng/codetest.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
g++ -std=c++11 code_tests/test.cpp -o testcode.o
|
||||||
|
./testcode.o
|
||||||
|
rm testcode.o
|
43
rng/rng/generators/LCG/lehmer.cpp
Normal file
43
rng/rng/generators/LCG/lehmer.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
//
|
||||||
|
// lehmer.cpp
|
||||||
|
// rng
|
||||||
|
//
|
||||||
|
// Created by Asher Falcon on 20/06/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../../rng.h"
|
||||||
|
|
||||||
|
// parameters recommended by Nakazawa & Nakazawa
|
||||||
|
// https://en.wikipedia.org/wiki/Lehmer_random_number_generator
|
||||||
|
|
||||||
|
uint64_t lehmer_minstd(uint64_t prev){
|
||||||
|
uint64_t a = 7759097958782935LL;
|
||||||
|
uint64_t m = 18055400005099021LL;
|
||||||
|
|
||||||
|
uint64_t result = (a * prev) % m;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
class lehmer_generator {
|
||||||
|
uint64_t seed;
|
||||||
|
public:
|
||||||
|
uint32_t generate(){
|
||||||
|
seed = lehmer_minstd(seed);
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
lehmer_generator(uint64_t genSeed){
|
||||||
|
seed = genSeed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// std::vector<std::bitset<32>> lehmer_generate(int seed, int amount){
|
||||||
|
// std::vector<std::bitset<32>> bits(amount);
|
||||||
|
|
||||||
|
// for(int i=0; i<amount; i++){
|
||||||
|
// seed = lehmer_minstd(seed);
|
||||||
|
// bits[i]=seed;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return bits;
|
||||||
|
// }
|
95
rng/rng/generators/mt19937.cpp
Normal file
95
rng/rng/generators/mt19937.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
#include "../rng.h"
|
||||||
|
|
||||||
|
// more specifically this will be mt19937 - 32 bit
|
||||||
|
|
||||||
|
std::array<uint32_t,624> mt19937_init(uint32_t seed){
|
||||||
|
|
||||||
|
std::array<uint32_t,624> state;
|
||||||
|
|
||||||
|
state[0] = seed;
|
||||||
|
|
||||||
|
for(int i=1; i<624; i++){
|
||||||
|
state[i]= 1812433253*(state[i-1] ^ (state[i-1] >> 30)) + i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<uint32_t,624> mt19937_twist(std::array<uint32_t,624> state){
|
||||||
|
|
||||||
|
std::array<uint32_t,624> newstate;
|
||||||
|
|
||||||
|
for(int i=0; i<624; i++){
|
||||||
|
uint32_t x;
|
||||||
|
|
||||||
|
// concating the MSB and LSB from next
|
||||||
|
if(i+1<624){
|
||||||
|
x = (state[i] & 0x80000000) | (state[(i+1)] & 0x7FFFFFFF);
|
||||||
|
}else{
|
||||||
|
x = (state[i] & 0x80000000) | (newstate[(i+1)%624] & 0x7FFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// does the *A part
|
||||||
|
if(x&1){
|
||||||
|
x = (x>>1) ^ 0x9908B0DFUL;
|
||||||
|
}else{
|
||||||
|
x=x>>1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t y;
|
||||||
|
if(i+397<624){
|
||||||
|
y = state[i+397] ^ x;
|
||||||
|
}else{
|
||||||
|
y = newstate[(i+397) % 624] ^ x;
|
||||||
|
}
|
||||||
|
newstate[i] = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newstate;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<uint32_t,624> mt19937_temper(std::array<uint32_t,624> state){
|
||||||
|
std::array<uint32_t, 624> tempered;
|
||||||
|
|
||||||
|
for(int i=0; i<624; i++){
|
||||||
|
|
||||||
|
uint32_t y = state[i];
|
||||||
|
y = y ^ (y >> 11);
|
||||||
|
y = y ^ ((y << 7) & 0x9D2C5680UL);
|
||||||
|
y = y ^ ((y << 15) & 0xEFC60000UL);
|
||||||
|
tempered[i] = y ^ (y >> 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempered;
|
||||||
|
}
|
||||||
|
|
||||||
|
class mt19937_generator {
|
||||||
|
public:
|
||||||
|
uint32_t seed;
|
||||||
|
uint32_t generate() {
|
||||||
|
uint32_t generated = random_values[position];
|
||||||
|
position++;
|
||||||
|
if(position>=624){
|
||||||
|
nextblock();
|
||||||
|
}
|
||||||
|
return generated;
|
||||||
|
}
|
||||||
|
double generate_01(){
|
||||||
|
return ((double)generate())/(4294967295);
|
||||||
|
}
|
||||||
|
mt19937_generator(uint32_t genSeed){
|
||||||
|
seed = genSeed;
|
||||||
|
state = mt19937_init(seed);
|
||||||
|
nextblock();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::array<uint32_t,624> state;
|
||||||
|
std::array<uint32_t,624> random_values;
|
||||||
|
int position;
|
||||||
|
// goes to next block of 624 values
|
||||||
|
void nextblock() {
|
||||||
|
state = mt19937_twist(state);
|
||||||
|
random_values = mt19937_temper(state);
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
};
|
52
rng/rng/main.cpp
Normal file
52
rng/rng/main.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// main.cpp
|
||||||
|
// rng
|
||||||
|
//
|
||||||
|
// Created by Asher Falcon on 17/06/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "rng.h"
|
||||||
|
#include "generators/LCG/lehmer.cpp"
|
||||||
|
#include "generators/mt19937.cpp"
|
||||||
|
#include "randomness_tests/frequency_monobit.cpp"
|
||||||
|
#include "randomness_tests/frequency_block.cpp"
|
||||||
|
#include "randomness_tests/runs.cpp"
|
||||||
|
|
||||||
|
int main(int argc, const char * argv[]) {
|
||||||
|
|
||||||
|
int seed = 8898;
|
||||||
|
int blocksgenerated = 1000000;
|
||||||
|
|
||||||
|
mt19937_generator mt2 = mt19937_generator(seed);
|
||||||
|
lehmer_generator lg = lehmer_generator(seed);
|
||||||
|
|
||||||
|
std::vector<std::bitset<32>> mtbits;
|
||||||
|
std::vector<std::bitset<32>> lgbits;
|
||||||
|
|
||||||
|
for(int i=0; i<blocksgenerated; i++){
|
||||||
|
mtbits.push_back(mt2.generate());
|
||||||
|
lgbits.push_back(lg.generate());
|
||||||
|
}
|
||||||
|
|
||||||
|
// for(auto bs : lgbits){
|
||||||
|
// for(int i=0; i<32; i++){
|
||||||
|
// std::cout << bs[i];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
int freqblocksize = (blocksgenerated * 32) / 120;
|
||||||
|
|
||||||
|
std::cout << "Linear Congruential Generator:\n";
|
||||||
|
std::cout << " - FreqMonobit = "<< std::fixed << std::setprecision(10) << test_frequency_monobit(lgbits) << "\n";
|
||||||
|
std::cout << " - FreqBlock (n/120) = "<< std::fixed << std::setprecision(10) << test_frequency_block(lgbits, freqblocksize) << "\n";
|
||||||
|
std::cout << " - Runs = "<< std::fixed << std::setprecision(10) << test_runs(lgbits) << "\n";
|
||||||
|
|
||||||
|
std::cout << "Mersenne Twister mt19937-32:\n";
|
||||||
|
std::cout << " - FreqMonobit = "<< std::fixed << std::setprecision(10) << test_frequency_monobit(mtbits) << "\n";
|
||||||
|
std::cout << " - FreqBlock (n/120) = "<< std::fixed << std::setprecision(10) << test_frequency_block(mtbits, freqblocksize) << "\n";
|
||||||
|
std::cout << " - Runs = "<< std::fixed << std::setprecision(10) << test_runs(mtbits) << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
114
rng/rng/math/incomplete_gamma.cpp
Normal file
114
rng/rng/math/incomplete_gamma.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#include "../rng.h"
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
double igam(double a, double x) {
|
||||||
|
double maxlog = 7.09782712893383996732E2;
|
||||||
|
double machep = 1.11022302462515654042E-16;
|
||||||
|
double big = 4.503599627370496e15;
|
||||||
|
double biginv = 2.22044604925031308085e-16;
|
||||||
|
|
||||||
|
double ans, ax, c, r;
|
||||||
|
|
||||||
|
if( (x<=0 || a<=0)){
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (x>1.0 && x>a){
|
||||||
|
// return 1.0 - igamc(a,x);
|
||||||
|
// }
|
||||||
|
|
||||||
|
ax = a * std::log(x) - x - std::lgamma(a);
|
||||||
|
|
||||||
|
if (ax < -maxlog){
|
||||||
|
// std::cout << "max log error on incomplete gamma function\n";
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ax = std::exp(ax);
|
||||||
|
|
||||||
|
r = a;
|
||||||
|
c = 1.0;
|
||||||
|
ans = 1.0;
|
||||||
|
do {
|
||||||
|
r+=1;
|
||||||
|
c*= x/r;
|
||||||
|
ans +=c;
|
||||||
|
}while(c/ans > machep);
|
||||||
|
|
||||||
|
return ans * ax/a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// regularized left tail of incomplete gamma
|
||||||
|
// Q(s, x) = \frac{1}{\Gamma(s)} \int_x^\infty t^{s-1} e^{-t} \, dt
|
||||||
|
double igamc(double a, double x){
|
||||||
|
return 1-igam(a,x);
|
||||||
|
// double maxlog = 7.09782712893383996732E2;
|
||||||
|
// double machep = 1.11022302462515654042E-16;
|
||||||
|
// double big = 4.503599627370496e15;
|
||||||
|
// double biginv = 2.22044604925031308085e-16;
|
||||||
|
|
||||||
|
|
||||||
|
// if(x<=0 || a<=0){
|
||||||
|
// return 1.0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if( (x < 1.0 ) || ( x < a)){
|
||||||
|
// std::cout << "bad\n";
|
||||||
|
// return 1.0 - igam(a,x);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// double ax = a * std::log(x) - std::lgamma(a);
|
||||||
|
|
||||||
|
// // maxlog?
|
||||||
|
// if(ax < -maxlog){
|
||||||
|
// std::cout << "max log error on incomplete gamma function\n";
|
||||||
|
// return 0.0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ax = std::exp(ax);
|
||||||
|
|
||||||
|
// double y = 1.0 - a;
|
||||||
|
// double z = x + y + 1.0;
|
||||||
|
// double c = 0.0;
|
||||||
|
// double pkm2 = 1.0;
|
||||||
|
// double qkm2 = x;
|
||||||
|
// double pkm1 = x + 1.0;
|
||||||
|
// double qkm1 = z * x;
|
||||||
|
// double ans = pkm1/qkm1;
|
||||||
|
|
||||||
|
// double pk,qk,r,t,yc;
|
||||||
|
|
||||||
|
// t = 1.0;
|
||||||
|
|
||||||
|
// do {
|
||||||
|
// c+=1.0;
|
||||||
|
// y+=1.0;
|
||||||
|
// z+=2.0;
|
||||||
|
// yc = y*c;
|
||||||
|
// pk = pkm1 * z - pkm2 * yc;
|
||||||
|
// qk = qkm1 * z - qkm2 * yc;
|
||||||
|
// if (qk !=0){
|
||||||
|
// r = pk/qk;
|
||||||
|
// t = std::fabs((ans-r)/r);
|
||||||
|
// ans = r;
|
||||||
|
// }else{
|
||||||
|
// t = 1.0;
|
||||||
|
// }
|
||||||
|
// pkm2 = pkm1;
|
||||||
|
// pkm1 = pk;
|
||||||
|
// qkm2 = qkm1;
|
||||||
|
// qkm1 = qk;
|
||||||
|
// if(std::fabs(pk) > big){
|
||||||
|
// pkm2 *= biginv;
|
||||||
|
// pkm1 *= biginv;
|
||||||
|
// qkm2 *= biginv;
|
||||||
|
// qkm1 *= biginv;
|
||||||
|
// }
|
||||||
|
// std::cout << ans << "-\n";
|
||||||
|
// } while (t>machep);
|
||||||
|
|
||||||
|
// return ans * ax;
|
||||||
|
}
|
||||||
|
|
20
rng/rng/plot_data.py
Normal file
20
rng/rng/plot_data.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
x_coords = []
|
||||||
|
y_coords = []
|
||||||
|
|
||||||
|
with open("data.txt", "r") as file:
|
||||||
|
for line in file:
|
||||||
|
x_coords.append(float(line.split(",")[0]))
|
||||||
|
y_coords.append(float(line.split(",")[1]))
|
||||||
|
|
||||||
|
plt.figure(figsize=(10, 8))
|
||||||
|
plt.scatter(x_coords, y_coords, alpha=0.6, s=1)
|
||||||
|
plt.grid(True, alpha=0.3)
|
||||||
|
|
||||||
|
plt.axis('equal')
|
||||||
|
plt.xlim(-0.05, 1.05)
|
||||||
|
plt.ylim(-0.05, 1.05)
|
||||||
|
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.show()
|
51
rng/rng/randomness_tests/frequency_block.cpp
Normal file
51
rng/rng/randomness_tests/frequency_block.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
//
|
||||||
|
// frequency_monobit.cpp
|
||||||
|
// rng
|
||||||
|
//
|
||||||
|
// Created by Asher Falcon on 21/06/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../rng.h"
|
||||||
|
#include "../math/incomplete_gamma.cpp"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the p value from the block frequency test
|
||||||
|
*/
|
||||||
|
double test_frequency_block(std::vector<std::bitset<32>> data, u_long block_size){
|
||||||
|
|
||||||
|
// std::cout << "BLOCK SIZE: "<< block_size<<"\n";
|
||||||
|
|
||||||
|
long long bitcount = data.size() * 32;
|
||||||
|
long long chunks = bitcount / block_size;
|
||||||
|
|
||||||
|
double x2stat = 0;
|
||||||
|
|
||||||
|
for(int chunkIndex = 0; chunkIndex < chunks; chunkIndex++){
|
||||||
|
// std::cout << "NEWCHUNK: ";
|
||||||
|
double onecount = 0;
|
||||||
|
for(int i=0; i<block_size; i++){
|
||||||
|
int dataIndex = (((chunkIndex * block_size)+i) / 32);
|
||||||
|
int bitIndex = (((chunkIndex * block_size)+i) % 32);
|
||||||
|
onecount += data[dataIndex][bitIndex];
|
||||||
|
// std::cout << data[dataIndex][bitIndex];
|
||||||
|
}
|
||||||
|
double oneproportion = onecount / (double)block_size;
|
||||||
|
|
||||||
|
x2stat += 4*block_size*std::pow((oneproportion - 0.5),2);
|
||||||
|
|
||||||
|
// std::cout << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// std::cout << "[debug] calling igamc with "<<(chunks/2) <<','<<(x2stat/2) << "\n";
|
||||||
|
double p = igam(chunks/2, x2stat/2);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is recommended that each sequence to be tested consist of a minimum of 100 bits (i.e., n ≥ 100). Note
|
||||||
|
that n ≥ MN. The block size M should be selected such that M ≥ 20, M > .01n and N < 100.
|
||||||
|
*/
|
||||||
|
bool pass_frequency_monobit(std::vector<std::bitset<32>> data, int chunkSize){
|
||||||
|
double pv = test_frequency_block(data, chunkSize);
|
||||||
|
return pv >= 0.01;
|
||||||
|
}
|
35
rng/rng/randomness_tests/frequency_monobit.cpp
Normal file
35
rng/rng/randomness_tests/frequency_monobit.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// frequency_monobit.cpp
|
||||||
|
// rng
|
||||||
|
//
|
||||||
|
// Created by Asher Falcon on 21/06/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../rng.h"
|
||||||
|
|
||||||
|
|
||||||
|
double test_frequency_monobit(std::vector<std::bitset<32>> data){
|
||||||
|
|
||||||
|
long long s = 0;
|
||||||
|
|
||||||
|
for(auto bitset : data){
|
||||||
|
for(int i=0; i<32; i++){
|
||||||
|
s += (2*bitset[i])-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// std::cout << " [sval: "<<s<<"] ";
|
||||||
|
|
||||||
|
double sobs = ((double)std::abs(s))/std::sqrt(data.size()*32);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double pvalue = std::erfc(sobs/std::sqrt(2));
|
||||||
|
|
||||||
|
return pvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pass_frequency_monobit(std::vector<std::bitset<32>> data){
|
||||||
|
double pv = test_frequency_monobit(data);
|
||||||
|
return pv >= 0.01;
|
||||||
|
}
|
26
rng/rng/randomness_tests/runs.cpp
Normal file
26
rng/rng/randomness_tests/runs.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "../rng.h"
|
||||||
|
|
||||||
|
double test_runs(std::vector<std::bitset<32>> data){
|
||||||
|
|
||||||
|
long long totalSize = data.size() * 32;
|
||||||
|
|
||||||
|
double vnobs = 1;
|
||||||
|
|
||||||
|
double onesproportion = 0;
|
||||||
|
|
||||||
|
for(int i=0; i<totalSize-1; i++){
|
||||||
|
|
||||||
|
if(data[i/32][i%32]!=data[(i+1)/32][(i+1)%32]){
|
||||||
|
vnobs++;
|
||||||
|
}
|
||||||
|
onesproportion+=data[i/32][i%32];
|
||||||
|
}
|
||||||
|
|
||||||
|
onesproportion/=totalSize;
|
||||||
|
|
||||||
|
return std::erfc(
|
||||||
|
std::abs(vnobs-(2*totalSize*onesproportion*(1-onesproportion)))
|
||||||
|
/
|
||||||
|
(2*std::sqrt(2*totalSize)*onesproportion*(1-onesproportion))
|
||||||
|
);
|
||||||
|
}
|
16
rng/rng/rng.h
Normal file
16
rng/rng/rng.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// include.h
|
||||||
|
// rng
|
||||||
|
//
|
||||||
|
// Created by Asher Falcon on 20/06/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <array>
|
||||||
|
#include <random>
|
||||||
|
#include <vector>
|
||||||
|
#include <cmath>
|
||||||
|
#include <iomanip>
|
3
rng/rng/run.sh
Executable file
3
rng/rng/run.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
g++ -std=c++11 main.cpp -o main.o
|
||||||
|
./main.o
|
||||||
|
rm main.o
|
Loading…
x
Reference in New Issue
Block a user